[PHP] PHP Form and Arrays help

2002-09-24 Thread Tom Ray

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 (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PHP Form and Arrays help

2002-09-24 Thread Marek Kilimajer

Use either session to remember the checkboxes' name/value pairs or 
hidden fields.

Tom Ray wrote:

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 (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] PHP Form and Arrays help

2002-09-24 Thread Geoff

If I remember correctly checkboxes literally do not exist on the posted
pages if they don't get checked on the form page. So maybe you can use
isset or something like that to see if the checkbox exists if so make it
checked if not show it unchecked.

Hope that helps.

On Tue, 2002-09-24 at 11:24, Tom Ray wrote:
 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 (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php