Click to See Complete Forum and Search --> : Need help with list selection


Aronya1
09-09-2003, 03:36 PM
Hi All,

I have 3 lists; schools, churches, other.
I need to allow the user to choose ONE selection from any ONE of the 3 lists, but no others.

Is there a way to:
1. Use a radio button selection to determine which list would be displayed in a select field?
or
2. Use the 3 select fields like radio buttons, where a selection in one field would clear any other?

Thanks,
Aronya1

Jona
09-09-2003, 03:47 PM
Both of those are possible, and another possibility is to populate the values of the select box depending on which of the three radio boxes are checked.

[J]ona

Aronya1
09-09-2003, 03:52 PM
OK, I worded the question wrong. I'm sure there is a way...

The question should be "How?"

Is this a big job? Small enough for someone here to whip something up? Is there a script somewhere already put together I can modify?

Aronya1

ps Isn't this the same as my first choice?
another possibility is to populate the values of the select box depending on which of the three radio boxes are checked

Xin
09-09-2003, 05:37 PM
<select name="schools" onchange="this.form.churches.selectedIndex=-1; this.form.others.selectedIndex=-1">
<option ...>
</select>

<select name="churches" onchange="this.form.schools.selectedIndex=-1; this.form.others.selectedIndex=-1">
<option ...>
</select>

<select name="others" onchange="this.form.schools.selectedIndex=-1; this.form.churches.selectedIndex=-1">
<option ...>
</select>

Jona
09-09-2003, 05:41 PM
Originally posted by Aronya1
ps Isn't this the same as my first choice?

Heh, I thought you meant to have three select boxes and three corresponding radio buttons, all visible, all the time; and then whichever was checked would be submitted to the form. :rolleyes:

[J]ona

Aronya1
09-09-2003, 06:06 PM
Xin,
Thanks for the help, but I can still choose an option in all 3 select boxes if I try. I need to limit the user to only one choice. Care to try again?


Jona,
Your idea would work, too. I'm open to any suggestion that will leave me with only one value to be passed to the database. I'm just not a programmer, although I can understand enough to tweak things a little (read: get into trouble), so I need a hand.


Aronya1

Xin
09-09-2003, 07:10 PM
do you want to show one list only and need some trigger to switch the list content between schools, churches and others, or you want to show three lists at the same time but only one item from one list will be selected and submitted?

for this:

<body onload="document.forms.list.schools.selectedIndex=-1; document.forms.list.churches.selectedIndex=-1; document.forms.list.others.selectedIndex=-1">

<form name="list">

<select name="schools" onchange="this.form.churches.selectedIndex=-1; this.form.others.selectedIndex=-1">
<option ... >...</option>
</select>

<select name="churches" onchange="this.form.schools.selectedIndex=-1; this.form.others.selectedIndex=-1">
<option ... >...</option>
</select>

<select name="others" onchange="this.form.schools.selectedIndex=-1; this.form.churches.selectedIndex=-1">
<option ... >...</option>
</select>

</form>

</body>

when you pick one item from one list, the other two lists will get unselected and won't be submitted


if you only want one list visible but need to switch the options, you can take a look at this sample: http://yxscripts.com/sm/selectmenu.html, and here is the tool to create/edit a select menu: http://yxscripts.com/sm/tool/editor.html

thx,

Aronya1
09-09-2003, 07:48 PM
Xin,

Many many thanks. The code you posted is just what I need. And the links look very interesting, too. I'll be taking advantage of that editor.

Aronya1