Getting POSTed values from dynamically named checkboxes
| From: | Dillon, John | Date: | Thu, 29 May 2003 15:44:47 +0000 |
| Subject: | Getting POSTed values from dynamically named checkboxes | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-149441@lists.php.net to get a copy of this message | ||
My problem relates to IF statement in the following code. There are two
checkboxes, named altid$thisid, so for instance they become altid36 and
altid37. When the form is submitted with both checked, I can read the first
altid36, but the second does not pass the IF test. Any suggestions re
possible reasons?
$checkedalts = array();
$x=0;
$y=1;
$array_id = explode(",", $_POST["idlist"]);
foreach($array_id as $thisid){
if(${"altid" . $thisid} == 1){
//OR if(ISSET($_POST["${"altid" . $thisid}"])){
$checkedalts[$x] = $thisid;
$checkedalts[$y] = ${"altprice" . $thisid};
$x=$x+2;
$y=$x+1;
}
}
The HTML before submission is (without the <!--):
<!--
<tr>
<td>Whatever</td>
<td><input type="checkbox" name="altid36"
value="1"
></td>
<td class=textset22><input size="10" type=textfield
value="" name="altprice36"></td>
</tr><tr>
<td>Something else</td>
<td><input type="checkbox" name="altid37"
value="1"
></td>
<td><input size="10" type=textfield value=""
name="altprice37"></td>
</tr><tr>
//-->
Thanks,
John
Please reply to both cc and return address if not to the list.
http://www.cantor.com
CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are confidential. If you
are not the named recipient please notify the sender and immediately delete it. You may not
disseminate, distribute, or forward this e-mail message or disclose its contents to anybody else.
Copyright and any other intellectual property rights in its contents are the sole property of Cantor
Fitzgerald.
E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does
not accept liability for any errors or omissions in the contents of this message which arise as a
result of e-mail transmission. If verification is required please request a hard-copy version.
Although we routinely screen for viruses, addressees should check this e-mail and any
attachments for viruses. We make no representation or warranty as to the absence of viruses in this
e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection
of our customers and business, we may monitor and read e-mails sent to and from our server(s).
For further important information, please read the Important Legal Information and Legal Statement
at http://www.cantor.com/legal_information.html