Re: checkboxes
| From: | Shawn McKenzie | Date: | Tue, 21 Apr 2009 22:41:28 +0000 |
| Subject: | Re: checkboxes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-291778@lists.php.net to get a copy of this message | ||
PJ wrote:
> How to deactivate checkboxes when one in a series is checked?
> <input type="checkbox" name="choice[1]"><another input>
> <input type="checkbox" name="choice[2]"><another input1>
> <input type="checkbox" name="choice[3]"><another input2>
> <input type="checkbox" name="choice[4]"><another input3>
> So that only 1 of the other inputs could be used in a search. Probably
> do the rest with switch stuff.
> Would be neat if the deactivated checkboxes would go grey.
> Is this an HTML question? Use onclick?But I think I need to either use a
> php string or function or would this be a CSS thingy?
> Thanks for any help.
>
Actually, you would use javascript to do this. You may use CSS with it,
but javascript would trigger/do the deactivation/graying out.
Better to use radio buttons here. Only one in a group can be selected.
Use the same name for all in a group but assign a different value. You
can use numbers as the values or use the actual value from the DB maybe.
<input type="radio" name="choice" value="1">
<input type="radio" name="choice" value="2">
<input type="radio" name="choice" value="3">
<input type="radio" name="choice" value="4">
So on submit the value of $_POST['choice'] would be 1, 2, 3, or 4.
--
Thanks!
-Shawn
http://www.spidean.com