PDA

View Full Version : 2 lists



Beginner
Jun 24th, 2002, 01:25 AM
Hello,
I have two dropdown lists on a form. How can I make it so the user must select from list a or list b but not both?

Thanks for any help.
:confused:

glenngv
Jun 24th, 2002, 02:04 AM
Do the select tags have size > 1? and select multiple?

Beginner
Jun 24th, 2002, 02:52 AM
hi glenngv,
List A consists of Canadian Provinces, and List B consists of States. I want the applicant to choose only one state or one province. They must make a selection from one list only.
Thanks for your help, I appreciate it.

glenngv
Jun 24th, 2002, 03:12 AM
<select name="province" size="5" onchange="document.yourformname.state.selectedIndex=-1">

</select>
<select name="state" size="5" onchange="document.yourformname.province.selectedIndex=-1">

</select>

change the size to anything greater than 1 and yourformname to your appropriate form name



Originally posted by Beginner
hi glenngv,
List A consists of Canadian Provinces, and List B consists of States. I want the applicant to choose only one state or one province. They must make a selection from one list only.
Thanks for your help, I appreciate it.

Beginner
Jun 24th, 2002, 03:27 AM
Hello,
Thanks so much, it's exactly what I needed. :thumbsup:

Beginner
Jun 24th, 2002, 11:53 PM
Greetings,
Is it possible to ensure that a selection has been made from one list or the other, via an 'alert' if both are left unselected?
Thanks for any help. :confused:

glenngv
Jun 26th, 2002, 06:27 AM
function check(){
frm = document.yourformname;
if (frm.province.selectedIndex==-1 && frm.state.selectedIndex==-1){
alert("You must choose a province or a state.");
return false;
}
//other checking here

return true;
}

<form onsubmit="return check()" ...>


Originally posted by Beginner
Greetings,
Is it possible to ensure that a selection has been made from one list or the other, via an 'alert' if both are left unselected?
Thanks for any help. :confused: