Hello,
i have many check boxes all named features, with different values, how do i collect their values in php and whats the best method to save an repopulate the form when its loaded, so tha it will show previously selected values.
thanks
Hello,
i have many check boxes all named features, with different values, how do i collect their values in php and whats the best method to save an repopulate the form when its loaded, so tha it will show previously selected values.
thanks
Checkboxes are are generated like this:
<input type='checkbox' name='mycheck' value="1" /> Unchecked checkbox
<input type='checkbox' name='mycheck' value="1" checked /> Checked checkbox
So you will output them with a code similar to this:
<input type='checkbox' name='<?=$checkName?>' <?=$checked?'checked':''?> value="1" /> <?=$checkLabel?>
To redisplay, you will need to prepare the appropriare variables, according to user's post. You could put all of them in an array, and cycle upon it to generate them all.
Some tricks with checkboxes:
<input type='checkbox' name='options[check1]' value="1" /> Unchecked checkbox <input type='checkbox' name='options[check2]' value="1" /> Unchecked checkbox
you will get an array called $_POST['options'] in your POST, with check1 and check2 as your keys.