
June 27th, 2000, 09:38 PM
|
|
Junior Member
|
|
Join Date: Jan 2000
Posts: 25
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> ---- </option>
<option value="1" <?if($dldNum==1):?>selected<?endif?>> 1</option>
<option value="2" <?if($dldNum==2):?>selected<?endif?>> 2</option>
<option value="3" <?if($dldNum==3):?>selected<?endif?>> 3</option>
<option value="4" <?if($dldNum==4):?>selected<?endif?>> 4</option>
<option value="5" <?if($dldNum==5):?>selected<?endif?>> 5 </option>
</select> 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?>> DS-1 (T1)<?echo $i?> </td>
<td class="input" style='font-size:8.5pt;;'><input type="checkbox" name="dldckDS3[]" value="1" <?if($dldckDS3[$i]==1):?>checked<?endif?>> DS-3 (T3)<?echo $i?></td>
</tr>
</table>
<?
++$i;
endwhile;
?>
<p>
<input type="submit" name="submitOrder" value="Submit Order">
</form>
Thanks again,
bob
|