I have a section of check boxes that load into a form if certain conditions are met. I can not make them retain their data if there are any errors in the rest of the form. The html that loads is:
Joseph Ribkoff
<input type="checkbox" name="keydesigners[]" value="Joseph Ribkoff" />
Tribal
<input type="checkbox" name="keydesigners[]" value="Tribal" />
French Dressing
<input type="checkbox" name="keydesigners[]" value="French Dressing" />
LaFie-Nier
<input type="checkbox" name="keydesigners[]" value="LaFie-Nier" />
Ravel
<input type="checkbox" name="keydesigners[]" value="Ravel" />
Maggy London
<input type="checkbox" name="keydesigners[]" value="Maggy London" />
London Times
<input type="checkbox" name="keydesigners[]" <value="London Times" />
It loads into a much larger form using the post method. I would put it all down, but it is humongous. The data posts just fine, but if there is an error and the page reloads, the rest of the form keeps it's data just fine by echoing the post data, but I can not figure out how to get the check boxes to stay checked or unchecked, depending.
I have googled this a bunch and most the methods don't work at all, a few even kill my whole script. The only one that I have seen that does anythin in the right direction is this foreach construct I read on some random forum, but it checks all the boxes even if only one was checked. The foreach was like this:
foreach ($keydesigners as $ch) {
if ($ch='on') {
$checked = 'checked ';
} else {
unset ($checked);
}
}
And of course I stuck a php block in each input as such:
<input type="checkbox" name="keydesigners[]" <?php echo $checked; ?>value="Joseph Ribkoff" />
What am I doing wrong? I have looked all over and I can't seem to find a solution that works.
Thanks for reading this whole behemoth.
Kat