My html input tags take arrays.Im not able to retrieve them from javascript
<pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
        &lt;title&gt;Order&lt;/title&gt;
</code></pre>

<p>The following calculates the total based on the checkboxes selected and gives a confirm box.displaying the total.No matter what this total shows as 0.</p>

<pre><code>        &lt;script type="text/javascript"&gt;
         function validate()
           {
              var x,y,i,j,p=0;
        j=parseInt(document.getElementById('loopcount').value);
              document.write(j);
        for (i=1;i&lt;=j;i++)
        {
            document.write(i);
               if(document.getElementsByName('itemCode['+i+']').checked==true){
                x=parseFloat( document.getElementsByName('quantity['+i+']').value);
                document.write(x);
                y=parseFloat( document.getElementsByName('price['+i+']').value);
                document.write(y);
        p+=x*y;
                }
        }

    var conf=confirm("The total amount is:"+ p);

              if(conf==true){
                  header("Location:userHome.php");
              }
              else{
                  header("Location:orderveggies.php");
              }

        }


    &lt;/script&gt;
    &lt;/head&gt;
</code></pre>

<p>This code displays the data from mysql as checkboxes.My problem lies with the naming of the input tags which take arrays</p>

<pre><code>    &lt;body&gt;
        &lt;form name="myForm" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="post" onsubmit="validate()"&gt;
        &lt;table align="center" border="0"&gt;
            &lt;tr&gt;

                &lt;th&gt;item Code&lt;/th&gt;
                &lt;th&gt;Vegetable&lt;/th&gt;
                &lt;th&gt;Price/KG&lt;/th&gt;
                &lt;th&gt;Quantity&lt;/th&gt;
            &lt;/tr&gt;


             &lt;?php

             $db=  mysqli_connect('localhost','root','','ourveggies')
                            or die("Error!Could not connect to the database");
                    $query="select itemCode,itemName,price from veggies";
                    $result=mysqli_query($db,$query)
                            or die("Error in query".mysqli_error($db));
                    $count=mysqli_num_rows($result);
                    while($row= mysqli_fetch_array($result)){?&gt;
                        &lt;tr&gt;
                        &lt;td&gt;&lt;input type="checkbox" name="itemCode[]" value="&lt;?php echo $row['itemCode']; ?&gt;"/&gt;&lt;?php echo $row['itemCode']; ?&gt;&lt;/td&gt;
                        &lt;td&gt;&lt;?php echo $row['itemName']; ?&gt;&lt;/td&gt;
                        &lt;td&gt;&lt;input type="hidden"  name="price[]" value="&lt;?php echo $row['price']; ?&gt;"/&gt;&lt;?php echo $row['price']; ?&gt;&lt;/td&gt;
                        &lt;td&gt;&lt;select name="quantity[]"&gt;
                                &lt;option value="0.00"&gt;--Quantity--&lt;/option&gt;
                                &lt;option value="0.100"&gt;100 gm&lt;/option&gt;
                                &lt;option value="0.250"&gt;250 gm&lt;/option&gt;
                                &lt;option value="0.500"&gt;500 gm&lt;/option&gt;
                                &lt;option value="1"&gt;1 Kg&lt;/option&gt;
                                &lt;option value="2"&gt;2 Kg&lt;/option&gt;
                                &lt;option value="3"&gt;3 Kg&lt;/option&gt;
                                &lt;option value="4"&gt;4 Kg&lt;/option&gt;
                                &lt;option value="5"&gt;5 Kg&lt;/option&gt;

                            &lt;/select&gt;&lt;/td&gt;
                        &lt;/tr&gt;

                  &lt;?php  }?&gt;
                    &lt;input type="hidden" id="loopcount" name="loopcount" value="&lt;?php echo $count; ?&gt;"/&gt;

            &lt;tr&gt;
                &lt;td&gt;&lt;input type="submit" name="order" value="order" /&gt;&lt;/td&gt;
            &lt;/tr&gt;
        &lt;/table&gt;
        &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>
