Checkbox validation
Posted: Thu Oct 26, 2006 12:21 am
I have searched around the tutorial section prior to this post.
I have few questions to get understood.
Here are the codes:
Questions abou these code here:
1. How can I make an option in any kind of forms to "SELECT ALL".
2. How about if I want to evaluate uncheck all checkboxes and print "NONE WAS SELECTED" on the output page.
Because when I process this piece of code here would occur the error below:
I have few questions to get understood.
Here are the codes:
Code: Select all
<form action="check_valid.php" method="post">
<input type="checkbox" name="maj[]" value="Information Technology">Information Technology<br>
<input type="checkbox" name="maj[]" value="Business Administration">Business Administration<br>
<input type="checkbox" name="maj[]" value="Interpersonal Skills">Interpersonal Skills<br>
<input type="checkbox" name="maj[]" value="Operating Systems">Operating Systems<br>
<input type="checkbox" name="maj[]" value="Network Management">Network Management<br>
<input type="checkbox" name="maj[]" value="Data Communications">Data Communications<br>
<input type="checkbox" name="maj[]" value="Database Management">Database Management<br>
<input type="checkbox" name="maj[]" value="Artifical Intelligence">Artifical Intelligence<br>
<input type="radio" name="sex" value="M" CHECKED>Male<br>
<input type="radio" name="sex" value="F">Female<br>
<input type="submit" value="CHECK ORDER">
</form>Code: Select all
<?php
foreach($_POST['maj'] as $course)
{
echo $course."<br>";
}
$gen=$_POST['sex'];
if($gen=="M")
{
echo "GOOD BOY";
}
elseif($gen=="F")
{
echo "GOOD GAL";
}
?>1. How can I make an option in any kind of forms to "SELECT ALL".
2. How about if I want to evaluate uncheck all checkboxes and print "NONE WAS SELECTED" on the output page.
Because when I process this piece of code here would occur the error below:
Thanks in advance.Warning: Invalid argument supplied for foreach() in c:\program files\easyphp1-8\www\validation\check_valid.php on line 2