If you're using php3 (which looks like the case):
Forget about javascript and do the error checking in php instead- It's more reliable and foolproof that way anyway. Try something like this:
if (!isset($bar)) {
?>
<html>
error page here...
</html>
<?php
exit;
}
That should work, assuming the isset() construct is valid in php3.
If you're using php 4, you could still go with the javascript method, and just change the checkbox names to bar1, bar2, etc. so that javascript can use them. Then in PHP you could recreate the array from those names with the following code, making use of the $_POST array:
foreach ($_POST as $key => $val) {
if (substr($key, 0, 3) == "bar") { $bar[] = $val; }
}
Hope that helps.