use a hidden input in front of each checkbox with the same name and
the value '0' (as opposed to '1' for the checkbox).


> -----Original Message-----
> From: Tom Ray [mailto:[EMAIL PROTECTED]]
> Sent: 24 September 2002 17:24
> Subject: PHP Form and Arrays help
> I'm having a small problem with a form I'm designing and I 
> hope someone can
> point me in the right direction here. The form's function is 
> rather simple
> actaully. It's supposed to take the information, run through 
> it to make sure
> all the required fields have data in them, if there is a 
> blank required field
> it is supposed to redraw the form showing the field missed 
> but also store the
> data that was already submitted so you don't have to fill the 
> form out all over
> again. Now I have it so it stores the values of text boxes, 
> drop down menus and
> radio buttons but I'm having a real tough time with the check 
> box values.
> Example of what I'm doing: (Gender Selection with Radio Buttons). 
> I declare an array in my PHP by doing 
> $genderarray=array();
> Then I store the value of the form for the redraw like so:
> $mygender=$HTTP_POST_VARS[gender];
> $genderarray[$mygender]="checked";
> In the actaul form I decalre a global:
> global genderarray();
> And under the gender selection I have:
> <input name=gender type=radio value="Male" <?= 
> $genderarray["Male"] ?>" >
> (works the same for the Female)
> Now my question is how can I do this with check boxes. I 
> thought I could
> through them all into a single array, then pull out the ones 
> who have values to
> them, but that's not working the way I thought.
> Any thoughts or suggestions?

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to