Forum Moderators: coopster
source code of html file :
<html>
<head>
<title>Checkbox Demo</title>
</head>
<body>
<h1>Checkbox Demo</h1>
<h3>Demonstrates checkboxes</h3>
<form action ="checkDemo.php">
<h3>What would you like with your order?</h3>
<ul>
<li><input type ="checkbox"
name ="chkFries"
value ="1.00">Fries
</li>
<li><input type ="checkbox"
name ="chkSoda"
value =".85">Soda
</li>
<li><input type ="checkbox"
name ="chkShake"
value ="1.30">Shake
</li>
<li><input type ="checkbox"
name ="chkKetchup"
value =".05">Ketchup
</li>
</ul>
<input type ="submit" name ="submit" value ="submit">
</form>
</body>
</html>
source code of php file :
<html>
<head>
<title>Checkbox Demo</title>
</head>
<body>
<h3>Demonstrates reading checkboxes</h3>
<?
print <<<HERE
chkFries: $chkFries <br>
chkSoda: $chkSoda <br>
chkShake: $chkShake <br>
chkKetchup: $chkKetchup <br>
<hr>
HERE;
$total = 0;
if (!empty($chkFries)){
print ("You chose Fries <br> \n");
$total = $total + $chkFries;
} // end if
if (!empty($chkSoda)){
print ("You chose Soda <br> \n");
$total = $total + $chkSoda;
} // end if
if (!empty($chkShake)){
print ("You chose Shake <br> \n");
$total = $total + $chkShake;
} // end if
if (!empty($chkKetchup)){
print ("You chose Ketchup <br> \n");
$total = $total + $chkKetchup;
} // end if
print ("The total cost is \$$total \n");
?>
</body>
</html>