I home school my daughter and am not familiar with javascript. She wrote two functions and then they are called in the body. But they are not doing as she intended...displaying the DishName and the DishDesc.
I have spent all night trying to figure this one out, but I really don't know what is wrong with it. Maybe someone can help us out.
Here is the code so far:
<html>
<head>
<title>Kelsey's Dinner Menu</title>
<script language="JavaScript">
<!--- Hide from non-JavaScript browsers
function DishName(Day) {
var DName=new Array();
DName[0]="Chicken Burrito Amigo";
DName[1]="Chicken Tajine";
DName[2]="Pizza Bella";
DName[3]="Salmon Fillet";
DName[4]="Greek-style Shrimp";
DName[5]="All-you-can-eat fish";
DName[6]="Prime Rib";
return Day[DName];
}
function DishDesc(Day) {
var DDesc=new Array();
DDesc[0]="Chicken with mushrooms, onions, and Montery
Jack cheese wrapped in a flour tortilla 9.95";
DDesc[1]="Chicken baked with garlic, olives, capers,
and prunes 8.95";
DDesc[2]="Large pizza with pesto, goat cheese, onions,
and mozzarella cheese. 8.95";
DDesc[3]="Grilled salmon with a spicy curry sauce and
baked potato. 9.95";
DDesc[4]="Shrimp, feta cheese, and tomatoes simmered
in basil and garlic. 9.95";
DDesc[5]="Deep-fried cod with baked potato and rolls.
9.95";
DDesc[6]="12-oz cut with baked potato, rolls, and
<dt>
<script language="JavaScript">
<!--- Start hiding from non-JavaScript browser
//Insert the titles of the nightly specials below
var Today=new Date();
var WeekDay=Today.getDay();
document.write(DishName(WeekDay));
//Stop hiding -->
</script>
<dd>
<script language="JavaScript">
<!--- Start hiding from non-JavaScript browser
//Insert the descriptions of the nightly specials below
var Today=new Date();
var WeekDay=Today.getDay();
document.write(DishDesc(WeekDay));
//Stop hiding -->
</script>
<dt><hr>Cajun Meatloaf
<dd>Lean beef served with Kelsey's Southwestern mashed
potatoes. 8.95
<dt>Chicken Marsala
<dd>Plump chicken breasts sauteed with tomatoes,
mushrooms, & artichoke hearts
with a splash of Marsala wine. 8.95
<dt>Pecan Crusted Whitefish
<dd>Quickly seared fish & fresh mushrooms served with
I've cleaned up your code a bit. You had unclosed tags and there is still deprecated html code but it isn't affecting the way the javascript works so I haven't cleaned it out.
I simplified your 2 functions into a single 2 dimensional array where each row in the array contains the dishname and its corresponding description.
When the page loads the onload function loads the dishname for the day and its description into the appropriate elements.
Code:
<html>
<head>
<title>Kelsey's Dinner Menu</title>
<script type="text/javascript">
var dishData = new Array();
dishData = [
['Chicken Burrito Amigo','Chicken with mushrooms, onions, and Montery.<br />Jack cheese wrapped in a flour tortilla 9.95'],
['Chicken Tajine','Chicken baked with garlic, olives, capers,and prunes 8.95'],
['Pizza Bella','Large pizza with pesto, goat cheese, onions,and mozzarella cheese. 8.95'],
['Salmon Fillet','Grilled salmon with a spicy curry sauce and baked potato. 9.95'],
['Greek-style Shrimp','Shrimp, feta cheese, and tomatoes simmered in basil and garlic. 9.95'],
['All-you-can-eat fish','Deep-fried cod with baked potato and rolls. 9.95'],
['Prime Rib','12-oz cut with baked potato, rolls, and dinner salad. 12.95']
];
window.onload=function(){
var Today=new Date();
var weekDay=Today.getDay();
document.getElementById('dtNightlySpecialName').innerHTML = dishData[weekDay-1][0];
document.getElementById('dtNightlySpecialDesc').innerHTML = dishData[weekDay-1][1];
}
</script>
</head>
<body>
<center>
<img src="dinner.jpg" alt="">
<h1><span style="font-size:x-large; color:green">
Dinner Menu</span><br>
Served 4:00 p.m. - 10:00 p.m.</h1>
<hr>
</center>
<h3>Today's Special</h3>
<dl>
<dt id="dtNightlySpecialName"></dt>
<dd id="dtNightlySpecialDesc"></dd>
<dt><hr>Cajun Meatloaf</dt>
<dd>Lean beef served with Kelsey's Southwestern mashed potatoes. 8.95</dd>
<dt>Chicken Marsala</dt>
<dd>Plump chicken breasts sauteed with tomatoes,
mushrooms, & artichoke hearts
with a splash of Marsala wine. 8.95
</dd>
<dt>Pecan Crusted Whitefish</dt>
<dd>Quickly seared fish & fresh mushrooms served with
pineapple chutney. 10.95
</dd>
<dt>Thai Stir Fry</dt>
<dd>Fresh crisp vegetables quickly sauteed, tossed
with Kelsey's spicy
peanut sauce, served over rice. 8.95
</dd>
<dt>Jambalaya</dt>
<dd>Plump shrimp, chicken, & spicy sausage slowly
simmered with tomatoes and
rice. 9.95
</dd>
<dt>Wild Rice Stuffed Squash</dt>
<dd>Winter squash stuffed with fresh harvest
vegetables & pecan rice, served
with pineapple chutney & melted Monterey Jack.
8.95
</dd>
<dt>Cuban Beans & Rice</dt>
<dd>Black turtle beans simmered with carrots,
tomatoes, & green peppers,
served over rice with spicy salsa, guacamole, &
flour tortillas. 7.95
</dd>
</dl>
</body>
</html>
Since we are so new to this, the changes are not understood. I am sure you wrote it much better, but we don't understand what was wrong in the first place. Thank you for trying to help, we are just lost.
Bookmarks