<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<?php
$_REQUEST["chkhob"];
if(isset($_REQUEST["btnsubmit"]))
{
$choise = array("cricket","football","polo","tennies");
foreach($choise as $key => $val)
{
//var_dump($_REQUEST["chkhob"]);
if(in_array($val, $_REQUEST["chkhob"]))
{
$chkbox[$key] = "CHECKED";
}
}
$result = implode(" , ", $_REQUEST["chkhob"]);
echo "Your Hobies: $result";
}
?>
</head>
<body>
<form name="hobbies" >
<p>Select Your Hobbies</p>
<input type="checkbox" name="chkhob[]" value="cricket" <?php $chkbox[0]; ?>>Cricket
<input type="checkbox" name="chkhob[]" value="football" <?php $chkbox[1]; ?>>FootBall
<input type="checkbox" name="chkhob[]" value="polo" <?php $chkbox[2]; ?>>Polo
<input type="checkbox" name="chkhob[]" value="tennies" <?php $chkbox[3]; ?>>Tennies
<br />
<input type="submit" value="Submit" name="btnsubmit" onclick="">
<input type="reset" value="Reset" name="btnreset">
</form>
</body>
</html>
prakash.pipil 0 Newbie Poster
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.