[PHP] Getting POSTed values from dynamically named checkboxes

2003-05-30 Thread Dillon, John
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
  tdWhatever/td
  tdinput type=checkbox name=altid36  value=1
/td
  td class=textset22input size=10 type=textfield
value= name=altprice36/td
/trtr
  tdSomething else/td
  tdinput type=checkbox name=altid37  value=1
/td
  tdinput size=10 type=textfield value=
name=altprice37/td
/trtr 
//--

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



Re: [PHP] Getting POSTed values from dynamically named checkboxes

2003-05-30 Thread David Grant
Dillon, John wrote:

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
  tdWhatever/td
  tdinput type=checkbox name=altid36  value=1
/td
  td class=textset22input size=10 type=textfield
value= name=altprice36/td
/trtr
  tdSomething else/td
  tdinput type=checkbox name=altid37  value=1
/td
  tdinput size=10 type=textfield value=
name=altprice37/td
/trtr 
//--

Not what you're looking for, but... are you sure you're doing this the 
easiest way?

Try putting your values in an array instead, e.g.

altid[36] and altprice[36]

Then access through:

foreach ($_POST['altid'] as $id = $value)
{
  $price = $_POST['altprice'][$id]
}
Regards,

David

--
David Grant
Web Developer
[EMAIL PROTECTED]
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744

**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**

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