please do this the way the picture describes it. Thanks The first screenshot at
ID: 3689251 • Letter: P
Question
please do this the way the picture describes it. Thanks
The first screenshot at right shows the initial rendering of the HTML document prob2.html. The radio buttons have name= "dessert"; the first has value="cake", and the second has value="pie''. A radio button can be selected not only by clicking directly on it but also by clicking its label. The radio buttons are inside a fieldset with the legend shown. The textbox for one's name has name ="name". When Submit is clicked, a GET request is sent to prob2.php.Explanation / Answer
Please check the below programs for your requirement. Paste the code according to the files specified and you can run the code..........
---- prob2.html----
<!doctype html>
<html lang="en">
<head>
<style>
legend {
display: block;
padding-left: 2px;
padding-right: 2px;
border: none;
}
</style>
<title>Deserts Document</title>
</head>
<body>
<form name="frm" action="prob2.php" method="get">
<fieldset>
<legend>Choose your dessert</legend>
<p>
<input type="radio" name="dessert" id="cake" value="cake"/>
<label for="cake">Cake</label><br/>
<input type="radio" name="dessert" id="pie" value="pie"/>
<label for="pie">Pie</label>
</p>
</fieldset>
<br/>
<p>Your name: <input type="text" name="name"></p>
<p><input type="submit" name="submit" value="Submit"></p>
</form>
</body>
</html>
---- prob2.php------------------------------------------------------------
<?php
$dessert = $_GET["dessert"];
$yourname= $_GET["name"];
if (isset($_GET["submit"]) && ($_GET["submit"]=="Submit"))
{
if($dessert=="cake")
{
echo "<form name="frm" action="prob2Cake.php" method="get">";
echo "<fieldset>";
echo " <legend>Extra topping</legend>";
echo " <p>";
echo " <input type="radio" name="top" id="topy" value="topy"/>";
echo " <label for="topy">Yes</label><br/>";
echo " <input type="radio" name="top" id="topn" value="topn"/>";
echo " <label for="topn">No</label>";
echo " </p>";
echo " </fieldset>";
echo " <br/>";
echo " <input type="hidden" name="name" value="".$yourname."">";
echo " <p><input type="submit" name="submit" value="Submit"></p>";
echo " </form>";
}
else if($dessert=="pie")
{
echo "<form name="frm" action="prob2Pie.php" method="get">";
echo "<fieldset>";
echo " <legend>Ice cream</legend>";
echo " <p>";
echo " <input type="radio" name="ice" id="icey" value="icey"/>";
echo " <label for="icey">Yes</label><br/>";
echo " <input type="radio" name="ice" id="icen" value="icen"/>";
echo " <label for="icen">No</label>";
echo " </p>";
echo " </fieldset>";
echo " <br/>";
echo " <input type="hidden" name="name" value="".$yourname."">";
echo " <p><input type="submit" name="submit" value="Submit"></p>";
echo " </form>";
}
else
echo "<a href="prob2.html">Get back</a>";
}
else
echo "There is a problem !!! Please <a href="prob2.html">click here</a> to get back";
?>
----- prob2Cake.php ----------------------------------------------------------------------------
<?php
$yourname = $_GET["name"];
$topping = $_GET["top"];
if (isset($_GET["submit"]) && ($_GET["submit"]=="Submit"))
{
if($topping == "topy")
echo $yourname." will have extra topping";
else if($topping == "topn")
echo $yourname." won't have extra topping";
else
echo "<a href="prob2.html">Get back</a>";
}
else
echo "There is a problem !!! Please <a href="prob2.html">click here</a> to get back";
?>
----- prob2Pie.php ---------------------------
<?php
$yourname = $_GET["name"];
$icecream = $_GET["ice"];
if (isset($_GET["submit"]) && ($_GET["submit"]=="Submit"))
{
if($icecream == "icey")
echo $yourname." will have ice cream";
else if($icecream == "icen")
echo $yourname." won't have ice cream";
else
echo "<a href="prob2.html">Get back</a>";
}
else
echo "There is a problem !!! Please <a href="prob2.html">click here</a> to get back";
?>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.