please help me for this web masters out there

my problem is:

i have a that pulls out information from the database

$query=mysql_query("select * from requirements)

$rnum=0;

echo "<form name='requirements' action='checkrequirements.php' method='post'>";
while ($requirements=mysql_fetch_array($query)){
$result=$requirements;
echo "<input type='checkbox' name='$result[$rnum]'>" . $result . "";

$rnum++;
}
echo "<input type='submit' value='Enroll'>";
echo "</form>";

before submitting this form to the next page, i want to validate first if all the check boxes are checked.. if not, there would be a prompt that says that all requirements must be checked..

please help me..

i don't know where to start..

i want to thank you...

in advance.. thanks..

change your line to:

echo "<input type='checkbox' name='results'>" . $result . "";

and then validate like this :

var total=0;
for(var i=0; i < document.form1.results.length; i++){
if(document.form1.results[i].checked)
total =total+1;
}
if(total!=document.form1.results.length)
alert("Please select all")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.