Click to See Complete Forum and Search --> : limiting choices with checkboxes


laria
12-06-2002, 11:42 PM
Hi :)

I understand that I need to use radio buttons when only one selection is wanted for an answer. I would like to have the days of the week and offer my visitors either the choice of one or two days that they can pick from the seven. How do I do this?

Thanks for any help! :)

Stefan
12-07-2002, 09:41 AM
You could use checkboxes instead of radio buttons, as this will alow users to automatically choose mutiple selection.

You will still need eg JavaScript to check that noone marks more then 2 boxes, but it seems simpler to code then using radiobuttons.

If you have access to serverside methods you could also do the form validation serverside and thus not have to rely on clientside scripting at all.

Zach Elfers
12-07-2002, 11:23 AM
Or you could make the radio buttons names different. When all their names are the same eg:

<input type="radio" name="radioset">
<input type="radio" name="radioset">
<input type="radio" name="radioset">
<input type="radio" name="radioset">

The visitor will only be able to select one.


If the names are different:

<input type="radio" name="radio1">
<input type="radio" name="radio2">
<input type="radio" name="radio3">
<input type="radio" name="radio4">

The visitor will be able to select more than one.

laria
12-07-2002, 11:59 AM
I didn't know that about the radio buttons so that's great to know. I ended up finding a little script at 3am this morning(by Dr Joe no less) that let me do what I was wanting to do. Thanks so much for the help/advice - it's most appreciated :)