lonelywolf
04-29-2011, 06:17 PM
Hello, codingForums Pals
I have a little inconsistency with a html form I am designing for a class assignment. In the assignment I have to execute javascript code on the page load that checks for the presence of existing cookies in the page, if no cookies were found, an alerts pops saying so. for this I embedded a function called "existing_cookies()" in the "window.onload" event that will check for cookies when the page loads por however for some extraneous reason the code sits unresponsive, I get no alert for that matter.
here is the code if someone can help me solve this puzzle
<html>
<head>
<title>Bagels order</title>
<style type type="text/css">
.heading{font-weigth:bold ; font-family:"comic sans ms"; font-size:30pt}
.subheading{font-weigth:bold ; font-family:"comic sans ms"; font-size:20pt}
.body{font-family:"comic sans ms"; font-size:8.5pt; font-weight:bold}
table{background-image:url(stucco.jpg)}
</style>
<script type="text/javascript">
window.onload=existing_cookies; //onload event handler that runs existing_cookies()
function existing_cookies();
{
if(document.cookie.length==0)
alert("No Default Bagel Order Information found");
}
function order_bagels()
{
}
</script>
</head>
<body>
<form name="myform">
<table border="1" width="100%">
<tr><td class="heading">Bernies Bagels Barn</td><td align="center" colspan="3"><img src="bagel.jpg" width="320px" height="240px"/></td></tr>
<tr align="center" class="body"><td>Bagel Type</td><td>Cream Cheese</td><td colspan="2">Quantity</td></tr>
<table border="1" width="49%" align="left">
<tr><td colspan="1" align="left" class="body">Cinammon</td></tr>
<tr><td colspan="1" align="left" class="body">Apple</td></tr>
<tr><td colspan="1" align="left" class="body">Chocolate Chip</td></tr>
<tr><td colspan="1" align="left" class="body">Egg</td></tr>
<tr><td colspan="1" align="left" class="body">Whole Wheaty</td></tr>
</table>
<table border="1" width="5%" align="left">
<tr><td align="center"><input type="radio" name="bagel_type"/></td></tr>
<tr><td align="center"><input type="radio" name="bagel_type"/></td></tr>
<tr><td align="center"><input type="radio" name="bagel_type"/></td></tr>
<tr><td align="center"><input type="radio" name="bagel_type"/></td></tr>
<tr><td align="center"><input type="radio" name="bagel_type"/></td></tr>
</table>
<table border="1" class="body" align="left" width="23%">
<tr><td align="left">Plain</td></tr>
<tr><td align="left">Low Fat Plain</td></tr>
<tr><td align="left">Garlic</td></tr>
<tr><td align="left">Cinnamon</td></tr>
<tr><td align="left">Fruit</td></tr>
</table>
<table class="body" border="0" width="23%" align="left">
<tr><td align="center"><input type="checkbox" name="plain"/></td></tr>
<tr><td align="center"><input type="checkbox" name="low_fat"/></td></tr>
<tr><td align="center"><input type="checkbox" name="garlic"/></td><td><input type="radio" name="qt"/>1/2 Dozen</td></tr>
<tr><td align="center"><input type="checkbox" name="cinnamon"/></td><td><input type="radio" name="qt"/>1 Dozen</td></tr>
<tr><td align="center"><input type="checkbox" name="fruit"/></td></tr>
</table>
<table border="1" width="100%">
<tr><td colspan="3" class="subheading" align="center">Functions</td></tr>
<tr align="center"><td><input type="button" value="Delete Default Order"/></td><td><input type="button" value="Make a New Default"/></td><td><input type="button" value="Load Default Order"/></td></tr>
<tr align="center"><td>Visits:<input type="text" size="3" readonly /></td><td><input type="button" value="Order Bagels" onclick="order_bagels()"/></td><td>Orders Placed:<input type="text" size="3" readonly /></td></tr>
</table>
</table>
</form>
</body>
</html>
I have a little inconsistency with a html form I am designing for a class assignment. In the assignment I have to execute javascript code on the page load that checks for the presence of existing cookies in the page, if no cookies were found, an alerts pops saying so. for this I embedded a function called "existing_cookies()" in the "window.onload" event that will check for cookies when the page loads por however for some extraneous reason the code sits unresponsive, I get no alert for that matter.
here is the code if someone can help me solve this puzzle
<html>
<head>
<title>Bagels order</title>
<style type type="text/css">
.heading{font-weigth:bold ; font-family:"comic sans ms"; font-size:30pt}
.subheading{font-weigth:bold ; font-family:"comic sans ms"; font-size:20pt}
.body{font-family:"comic sans ms"; font-size:8.5pt; font-weight:bold}
table{background-image:url(stucco.jpg)}
</style>
<script type="text/javascript">
window.onload=existing_cookies; //onload event handler that runs existing_cookies()
function existing_cookies();
{
if(document.cookie.length==0)
alert("No Default Bagel Order Information found");
}
function order_bagels()
{
}
</script>
</head>
<body>
<form name="myform">
<table border="1" width="100%">
<tr><td class="heading">Bernies Bagels Barn</td><td align="center" colspan="3"><img src="bagel.jpg" width="320px" height="240px"/></td></tr>
<tr align="center" class="body"><td>Bagel Type</td><td>Cream Cheese</td><td colspan="2">Quantity</td></tr>
<table border="1" width="49%" align="left">
<tr><td colspan="1" align="left" class="body">Cinammon</td></tr>
<tr><td colspan="1" align="left" class="body">Apple</td></tr>
<tr><td colspan="1" align="left" class="body">Chocolate Chip</td></tr>
<tr><td colspan="1" align="left" class="body">Egg</td></tr>
<tr><td colspan="1" align="left" class="body">Whole Wheaty</td></tr>
</table>
<table border="1" width="5%" align="left">
<tr><td align="center"><input type="radio" name="bagel_type"/></td></tr>
<tr><td align="center"><input type="radio" name="bagel_type"/></td></tr>
<tr><td align="center"><input type="radio" name="bagel_type"/></td></tr>
<tr><td align="center"><input type="radio" name="bagel_type"/></td></tr>
<tr><td align="center"><input type="radio" name="bagel_type"/></td></tr>
</table>
<table border="1" class="body" align="left" width="23%">
<tr><td align="left">Plain</td></tr>
<tr><td align="left">Low Fat Plain</td></tr>
<tr><td align="left">Garlic</td></tr>
<tr><td align="left">Cinnamon</td></tr>
<tr><td align="left">Fruit</td></tr>
</table>
<table class="body" border="0" width="23%" align="left">
<tr><td align="center"><input type="checkbox" name="plain"/></td></tr>
<tr><td align="center"><input type="checkbox" name="low_fat"/></td></tr>
<tr><td align="center"><input type="checkbox" name="garlic"/></td><td><input type="radio" name="qt"/>1/2 Dozen</td></tr>
<tr><td align="center"><input type="checkbox" name="cinnamon"/></td><td><input type="radio" name="qt"/>1 Dozen</td></tr>
<tr><td align="center"><input type="checkbox" name="fruit"/></td></tr>
</table>
<table border="1" width="100%">
<tr><td colspan="3" class="subheading" align="center">Functions</td></tr>
<tr align="center"><td><input type="button" value="Delete Default Order"/></td><td><input type="button" value="Make a New Default"/></td><td><input type="button" value="Load Default Order"/></td></tr>
<tr align="center"><td>Visits:<input type="text" size="3" readonly /></td><td><input type="button" value="Order Bagels" onclick="order_bagels()"/></td><td>Orders Placed:<input type="text" size="3" readonly /></td></tr>
</table>
</table>
</form>
</body>
</html>