PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 27th, 2000, 09:38 PM
bbarker bbarker is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Posts: 25 bbarker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I've been looking at some code and the net for the past few hours trying to figure out what's wrong and I'm stumped. I have a form - multiple checkboxes (different names) and text fields going into an array. The text fields behave fine - the values from the first entry will populate elements of the first array. The weird part is that the check boxes will pass the correct values but not always to the correct array element. For example, given two check boxes in a 2 element array, if you check the 1st box in the first element and the 2nd in the second element, on submission, the second element populates the first array element. I've included a snippet of the code as an example - it's echoing things like crazy because I've been trying to see what's been going on. I hope someone can figure this out for me 'cause I'm completely stuck and am on a deadline. Thanks in advance.


<?
if($submitOrder){
for ($i=0; $i < $dldNum; ++$i){
echo "<p>i=$i<br>";
echo "dldckDS1[$i] - $dldckDS1[$i]<br>";
echo "dldckDS3[$i] - $dldckDS3[$i]<br>";
echo "('$dldsalesID','$dldNum',$dldckDS1[$i]','$dldckDS3[$i]','$dldck1YR[$i]','$dldck3YR[$i]','$dldck5YR[$i]','$dldNXX[$i]','$dldAddress[$i]','$dldCity[$i]','$dldState[$i]','$dldZip[$i] ','$dldComments')";
}
}

?>
<head>
<script language="JavaScript" type="text/javascript">
<!--
function Gothere()
{
this.document.ckTest.submit();
return true;
}
//-->
</SCRIPT>

</head>
<form method="post" name="ckTest" action="ckTest.phtml">
<select name="dldNum" onChange="Gothere()">
<option>&nbsp;----&nbsp;</option>
<option value="1" <?if($dldNum==1):?>selected<?endif?>>&nbsp;1</option>
<option value="2" <?if($dldNum==2):?>selected<?endif?>>&nbsp;2</option>
<option value="3" <?if($dldNum==3):?>selected<?endif?>>&nbsp;3</option>
<option value="4" <?if($dldNum==4):?>selected<?endif?>>&nbsp;4</option>
<option value="5" <?if($dldNum==5):?>selected<?endif?>>&nbsp;5&nbsp;&nbsp;&nbsp;</option>
</select>&nbsp;&nbsp;Select number of locations needing service.
<?
$num=$dldNum;
$i=0;
while ($i< $num):
?>
<table border="0" cellspacing="0" cellpadding="0" width="338">
<tr>
<td class="input" style='font-size:8.5pt;'><input type="checkbox" name="dldckDS1[]" value="1" <?if($dldckDS1[$i]==1):?>checked<?endif?>>&nbsp;DS-1 (T1)<?echo $i?>&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td class="input" style='font-size:8.5pt;;'><input type="checkbox" name="dldckDS3[]" value="1" <?if($dldckDS3[$i]==1):?>checked<?endif?>>&nbsp;DS-3 (T3)<?echo $i?></td>
</tr>
</table>

<?
++$i;
endwhile;
?>

<p>
<input type="submit" name="submitOrder" value="Submit Order">
</form>


Thanks again,

bob

Reply With Quote
  #2  
Old June 27th, 2000, 11:45 PM
Anti Anti is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 32 Anti User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Check boxes don't get returned if they're not checked - it's as if they're not even there. So there's no way to separate them the way you want without renaming the fields... Didn't go through it thoroughly, but maybe you could go with name="dldckDS1[$i]" and work with it that way?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Trouble passing checkbox values into the correct arrays

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap