Add some debugging code. Are you sure 36 and 37 end up in the $array_id
array? Try printing out $_POST['idlist'] and $thisid as you loop through
this thing to figure out where/what is getting skipped.

Ditto the idea on doing this another, way, btw... :)

---John Holmes...

----- Original Message -----
From: "Dillon, John" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 29, 2003 11:44 AM
Subject: [PHP] Getting POSTed values from dynamically named checkboxes


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


--
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

Reply via email to