Javascript select all button in php
<p>Hi All  First of all I don't know Javascript, I got this script from the internet but can't get it to work.  If someone can please be so kind and assist me.  I'm trying to create a "check all" &amp; "uncheck all" button on my form for my checkboxes, if I click the button it does not select anything.  Where am I going wrong?</p>

<pre><code>&lt;?php
session_start();
?&gt;
&lt;head&gt;
&lt;SCRIPT LANGUAGE="JavaScript"&gt;
&lt;!--

&lt;!-- Begin
function CheckAll(chk)
{
for (i = 0; i &lt; chk.length; i++)
chk[i].checked = true ;
}

function UnCheckAll(chk)
{
for (i = 0; i &lt; chk.length; i++)
chk[i].checked = false ;
}
// End --&gt;
&lt;/script&gt;
&lt;/head&gt;
</code></pre>

<p>And then the form:</p>

<pre><code>$sql0 = "SELECT * FROM .....
$result0 = mysql_query($sql0);
echo "&lt;form name='myform' action='...' method='post'&gt;";
while($row0 = mysql_fetch_assoc($result0)) {
   $test_id=$row0['id'];
   $test_name=$row0['test_name'];

echo "  &lt;table width=600px&gt;";
echo "      &lt;tr&gt;";
echo "          &lt;td width=30px&gt;&lt;input name='question[$test_id][]' type='checkbox' value='1' /&gt;&lt;/td&gt;";
echo "          &lt;td width=580px align=left&gt;$test_name&lt;/td&gt;";
echo "      &lt;/tr&gt;";
echo "  &lt;/table&gt;";
}
echo "&lt;/P&gt;";
echo "&lt;input type='button' name='Check_All' value='Check All' onClick='CheckAll(document.myform.check_list)'&gt;";
echo "&lt;input type='button' name='Un_CheckAll' value='Uncheck All' onClick='UnCheckAll(document.myform.check_list)'&gt;";
echo "&lt;/form&gt;";
</code></pre>
