0

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..

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Shanti C
1

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")
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.