...

View Full Version : form variables



acorath
12-24-2003, 04:40 PM
On page A i have a list of items with checkboxes, each with unique names.

when i press the submit button, what I want is to have the following page list off what has been checked.

Is there a way for page "b" to list all the checked off variables and ignore the unchecked variables, without actually typing out an individual command for each item?

acorath
12-25-2003, 01:43 AM
nevermind. I've decided to go about it a different way...

<edit>

actually though, if anyone has an answer, it would still be nice to know for days to come.

celestine
12-26-2003, 09:18 AM
nvm. sorry

raf
12-26-2003, 10:53 AM
You can loop through the post-collection like this


foreach ($_POST as $varName => $value){
echo ($varName . " = " . $value);
}

This will print all formfield-names and there values
But this also includes the submitbutton etc.

If you only want the checkboxes, then you best give them all a name that start with the same x-letters (+ maybe the same value, although that isn't necessary). Like "del" or so, and then you can so something like


foreach ($_POST as $varName => $value){
if ((substr($varName,0,3) == 'del') and ($value=='1')) {
echo ($varName . " = " . $value);
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum