Entry
How do I know which check boxes have been clicked from any number of boxes.
Jul 15th, 2000 07:02
Rini Setiadarma, Chirag Mehta, Ben Udall,
Here's an example :
<INPUT type=checkbox name="choice[]" value="one">One
<INPUT type=checkbox name="choice[]" value="two">Two
<INPUT type=checkbox name="choice[]" value="three">Three
<INPUT type=checkbox name="choice[]" value="four">Four
If the first and the third checkboxes have been clicked, you will have
an array variable $choice which contains :
$choice[0] = "one"
$choice[1] = "three"
Then you can process it as usual, e.g. :
for($i=0; $i<count($choice); $i++) echo $choice[$i];
Remember to give all checkboxes a same name with '[]' behind it.