1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Rep Power
    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.

    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')";

    <script language="JavaScript" type="text/javascript">
    function Gothere()
    return true;

    <form method="post" name="ckTest" action="ckTest.phtml">
    <select name="dldNum" onChange="Gothere()">
    <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.
    while ($i< $num):
    <table border="0" cellspacing="0" cellpadding="0" width="338">
    <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>


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

    Thanks again,

  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Rep Power
    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?

Similar Threads

  1. editing checkbox values
    By skootz in forum PHP Development
    Replies: 9
    Last Post: February 16th, 2004, 08:26 AM
  2. passing checkbox 'name' into a function?
    By jreider in forum HTML Programming
    Replies: 3
    Last Post: February 15th, 2004, 08:30 PM
  3. Inserting checkbox values from an array into MySQL
    By outlyr242 in forum PHP Development
    Replies: 1
    Last Post: February 9th, 2004, 04:28 PM
  4. Calculate the array values of checkbox results
    By schieb in forum ASP Programming
    Replies: 2
    Last Post: February 2nd, 2004, 10:46 PM
  5. Zip code validation
    By krwyth in forum MySQL Help
    Replies: 2
    Last Post: January 5th, 2004, 01:29 PM

IMN logo majestic logo threadwatch logo seochat tools logo