Checking the state of Checkboxes in PHP
Posted: Tue Sep 10, 2002 8:03 am
I have two forms. In form 1 the user checks checkboxes and in the second form. A PHP script checks the state of these checkboxes. The code is something like this:
Form 1:
----------
<input type="checkbox" name="product[][0]" value="">
<input type="text" name="product[][1]" value="">
<inpu type="text" name="product[][2]" value="">
Form 2:
----------
foreach($product as $value) {
if ($value[0] == "on") {
print "$value[1]\n";
print "$value[2]\n";
}
}
The values do get submitted to the form2 and I'm able to print out
$value[0]. It prints out as "on", but the if statement fails. If tried
trim($value[0]) it still doesn't work.
If anybody can give me help with this I will be extremely grateful.
Thanks
Tony
Form 1:
----------
<input type="checkbox" name="product[][0]" value="">
<input type="text" name="product[][1]" value="">
<inpu type="text" name="product[][2]" value="">
Form 2:
----------
foreach($product as $value) {
if ($value[0] == "on") {
print "$value[1]\n";
print "$value[2]\n";
}
}
The values do get submitted to the form2 and I'm able to print out
$value[0]. It prints out as "on", but the if statement fails. If tried
trim($value[0]) it still doesn't work.
If anybody can give me help with this I will be extremely grateful.
Thanks
Tony