JavaScript and PHP parameters
<p>I have a form that I validate it using the JavaScript.</p>

<p>Now when I submit the form I can't use the check boxes in that form.</p>

<p>This is a part of my JS that counts and validates the check boxes.</p>

<pre><code>&lt;script type="text/javascript"&gt;
function validateForm()
{
    //My Declarations
    var cases = addClients.caseType.length;
    var total = 0;
    var fnReturn = true;
    //My Script goes here
    for (var idx = 0; idx &lt; cases; idx++)
    {
        if (addClients.caseType[idx].checked == true)
        total += 1;
    }
    if (total == 0)
    {
        document.getElementById('caseErr').style.visibility =" visible";
        fnReturn = false;
    }
    else
       document.getElementById('caseErr').style.visibility = "hidden";

    return (fnReturn == true)?true:false;
}
&lt;/script&gt;
</code></pre>

<p>The next page that the form submits the data to is as follows (the portion of the check boxes):</p>

<pre><code>&lt;?php
$cases = $_POST['caseType'];
for ($i=0;$i&lt;count($cases);$i++)
    echo "&lt;li&gt;$cases[$i] \n";
</code></pre>

<p>Echoing the <code>$cases</code> prints only one letter of the selected check box.</p>

<p>I want to know what I am doing wrong here.</p>

<p><strong>EDIT:</strong></p>

<p>This is my form</p>

<pre><code>&lt;form id="addClients" method="post" action="confirmAdd.php" onsubmit="return validateForm();"&gt;
&lt;table border="0"&gt;
    &lt;tr align="center"&gt;
        &lt;th align="center"&gt;Client Last Name:&lt;/th&gt;
        &lt;td colspan="3" align="center"&gt;&lt;input type="text" name="clname" width="300%"&gt;&lt;/td&gt;
        &lt;td id="lnErr" style="visibility:hidden"&gt;Last Name Required!&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr align="center"&gt;
        &lt;th align="center"&gt;Client First Name:&lt;/th&gt;
        &lt;td colspan="3" align="center"&gt;&lt;input type="text" name="cfname" width="300%"&gt;&lt;/td&gt;
        &lt;td id="fnErr" style="visibility:hidden"&gt;First Name Required!&lt;/td&gt;
     &lt;/tr&gt;
    &lt;tr align="center"&gt;
        &lt;th align="center"&gt;Client Telephone:&lt;/th&gt;
        &lt;td colspan="3" align="center"&gt;&lt;input type="text" name="ctel" width="300%"&gt;&lt;/td&gt;
        &lt;td id="telErr" style="visibility:hidden"&gt;Telephone Required (without hyphins '-')!&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr align="center"&gt;
        &lt;th&gt;Cases:&lt;/th&gt;
        &lt;td align="center"&gt;Rape&lt;input type="checkbox" name="caseType[]" value="rape"&gt;&lt;/td&gt;
        &lt;td align="center"&gt;Drug Accusition&lt;input type="checkbox" name="caseType[]" value="Drug Accusition"&gt;&lt;/td&gt;
        &lt;td align="center"&gt;Assult&lt;input type="checkbox" name="caseType[]" value="Assult"&gt;&lt;/td&gt;
        &lt;td id="caseErr" style="visibility:hidden"&gt;At least one required!&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;
&lt;input type="submit" value="Add Client"&gt;
&lt;/form&gt;
</code></pre>

<p><em><strong>SOLUTION:</strong></em></p>

<p>I have managed to find a solution to the problem by googling ...</p>

<p>first the name of each check box have []</p>

<pre><code>Rape&lt;input type="checkbox" name="caseType[]" value="rape"&gt;
Drug Accusition&lt;input type="checkbox" name="caseType[]" value="Drug Accusition"&gt;
Assult&lt;input type="checkbox" name="caseType[]" value="Assult"&gt;
</code></pre>

<p>then, in the javascript I added this part:</p>

<pre><code>var t=0;
var c=addClients['caseType[]'];
for(var i=0;i&lt;c.length;i++)
    c[i].checked?t++:null;
</code></pre>

<p>where <code>addClients</code> is the name of my form.</p>

<p>then I tried the PHP that I have attached, and it listed the values as it should.</p>
