Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > a little array query

Reply
Thread Tools

a little array query

 
 
Jai
Guest
Posts: n/a
 
      09-10-2003
hey guys, i was wondering if you could help me wit a little JS array
problem, my variables are comming up "undefined", check it out for
yourself...

<!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">

<html>
<head>
<title>Kelsey's Dinner Menu</title>
<style>
body {background-image:url(tan.jpg)}
h3 {color:blue}
dt {font-weight:bold; color:green}
</style>

<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 DName[Day];
}
function DishDesc(Day) {
var DDesc="new array()";
DDesc[0]="Chicken with mushrooms, onions, and Monterey 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 dinner salad";
return DDesc[Day];
}

// Stop hiding -->
</script>


</head>

<body>
<center><img src="dinner.jpg">
<h5><span style="font-size-large; color:green">
Dinner Menu</span><br>
Served 4:00 p.m. - 10:00 p.m.</h5><hr></center>
<dl>
<h3>Today's Special</h3>

<dt>
<script language="JavaScript">
<!--- Start hiding from non-JavaScript browser
var Today=new Date();
var ThisDay=Today.getDate();
var ThisMonth=Today.getMonth();
var ThisYear=Today.getFullYear();
var WeekDay=Today.getDay();
var SpecialDish=DishName(WeekDay);

//Insert the titles of the nightly specials below;

document.write(""+SpecialDish);

//Stop hiding -->
</script>

<dd>
<script language="JavaScript">
<!--- Start hiding from non-JavaScript browser
var Today=new Date();
var ThisDay=Today.getDate();
var ThisMonth=Today.getMonth();
var ThisYear=Today.getFullYear();
var WeekDay=Today.getDay();
var SpecialDesc=DishDesc(WeekDay);


//Insert the descriptions of the nightly specials below;

document.write(""+SpecialDesc);

//Stop hiding -->
</script>
 
Reply With Quote
 
 
 
 
VK
Guest
Posts: n/a
 
      09-10-2003
Remove quotes from all array declarations (what are they doing there?):
var DName=new Array();

Jai <> wrote in message
news: om...
> hey guys, i was wondering if you could help me wit a little JS array
> problem, my variables are comming up "undefined", check it out for
> yourself...
>
> <!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">
>
> <html>
> <head>
> <title>Kelsey's Dinner Menu</title>
> <style>
> body {background-image:url(tan.jpg)}
> h3 {color:blue}
> dt {font-weight:bold; color:green}
> </style>
>
> <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 DName[Day];
> }
> function DishDesc(Day) {
> var DDesc="new array()";
> DDesc[0]="Chicken with mushrooms, onions, and Monterey 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 dinner salad";
> return DDesc[Day];
> }
>
> // Stop hiding -->
> </script>
>
>
> </head>
>
> <body>
> <center><img src="dinner.jpg">
> <h5><span style="font-size-large; color:green">
> Dinner Menu</span><br>
> Served 4:00 p.m. - 10:00 p.m.</h5><hr></center>
> <dl>
> <h3>Today's Special</h3>
>
> <dt>
> <script language="JavaScript">
> <!--- Start hiding from non-JavaScript browser
> var Today=new Date();
> var ThisDay=Today.getDate();
> var ThisMonth=Today.getMonth();
> var ThisYear=Today.getFullYear();
> var WeekDay=Today.getDay();
> var SpecialDish=DishName(WeekDay);
>
> //Insert the titles of the nightly specials below;
>
> document.write(""+SpecialDish);
>
> //Stop hiding -->
> </script>
>
> <dd>
> <script language="JavaScript">
> <!--- Start hiding from non-JavaScript browser
> var Today=new Date();
> var ThisDay=Today.getDate();
> var ThisMonth=Today.getMonth();
> var ThisYear=Today.getFullYear();
> var WeekDay=Today.getDay();
> var SpecialDesc=DishDesc(WeekDay);
>
>
> //Insert the descriptions of the nightly specials below;
>
> document.write(""+SpecialDesc);
>
> //Stop hiding -->
> </script>



 
Reply With Quote
 
 
 
 
Chris Riesbeck
Guest
Posts: n/a
 
      09-10-2003
In article < >,
(Jai) wrote:

> hey guys, i was wondering if you could help me wit a little JS array
> problem, my variables are comming up "undefined", check it out for
> yourself...


>
> function DishName(Day) {
> var DName="new array()";


you're assigning a string to DName, not making an 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";


just say

var DName = ["Chicken Burrito Amigo",
"Chicken Tajine",
...
"Prime Rib"];

> return DName[Day];
> }



> function DishDesc(Day) {
> var DDesc="new array()";
> DDesc[0]="Chicken with mushrooms, onions, and Monterey 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 dinner salad";


same comment

> return DDesc[Day];
> }
>
> // Stop hiding -->
> </script>
>
>
> </head>
>
> <body>
> <center><img src="dinner.jpg">
> <h5><span style="font-size-large; color:green">
> Dinner Menu</span><br>
> Served 4:00 p.m. - 10:00 p.m.</h5><hr></center>
> <dl>
> <h3>Today's Special</h3>
>
> <dt>
> <script language="JavaScript">
> <!--- Start hiding from non-JavaScript browser
> var Today=new Date();
> var ThisDay=Today.getDate();
> var ThisMonth=Today.getMonth();
> var ThisYear=Today.getFullYear();
> var WeekDay=Today.getDay();
> var SpecialDish=DishName(WeekDay);
>
> //Insert the titles of the nightly specials below;
>
> document.write(""+SpecialDish);
>
> //Stop hiding -->
> </script>
>
> <dd>
> <script language="JavaScript">
> <!--- Start hiding from non-JavaScript browser
> var Today=new Date();
> var ThisDay=Today.getDate();
> var ThisMonth=Today.getMonth();
> var ThisYear=Today.getFullYear();
> var WeekDay=Today.getDay();
> var SpecialDesc=DishDesc(WeekDay);
>
>
> //Insert the descriptions of the nightly specials below;
>
> document.write(""+SpecialDesc);
>
> //Stop hiding -->
> </script>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
1 little 2 little 3 little Kennedys dale Digital Photography 0 03-23-2008 01:03 PM
having a little problem with some code for a little game I am creating. ThaDoctor C++ 3 09-28-2007 03:28 PM
A little bit confused about array+array addition (bug or expected behavior?) gga Ruby 6 02-17-2005 02:03 PM
little red X in little white box Puzzled Computer Support 8 12-13-2004 09:11 AM
Little query Peter Hickman Ruby 9 07-22-2004 01:05 PM



Advertisments