while($row = mysql_fetch_array($query))
{
echo "<input type=checkbox name=myCheckbox[] value=$row[id]><br>";
}

I want to include a select all and a deselect all link at the end of the form, but the typical javascript online only works for when the name=myCheckbox and not name=myCheckbox[]. I need to have the brackets because I handle $_POST['myCheckbox'] as an array. How would I go about doing this?

Thanks a lot. I appreciate any input you can provide me.

    try giving the checkbox an id (f.ex. cb1, cb2, cb3, cb4, etc.). then have js refer to it by the id, not by its name. hope that helps!

    echo "<input type=\"checkbox\" name=\"myCheckbox[]\" value=\"" . $row[id] . "\" id=\"cb" . $cnt++ . "\"><br>";

      Also note that you need to have quotes around the values of your HTML attributes.

        Write a Reply...