a little array query

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jai

    #1

    a little array query

    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.dt d">
    <html xmlns="http://www.w3.org/1999/xhtml">

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

    <script language="JavaS cript">
    <!-- 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:x-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="JavaS cript">
    <!--- Start hiding from non-JavaScript browser
    var Today=new Date();
    var ThisDay=Today.g etDate();
    var ThisMonth=Today .getMonth();
    var ThisYear=Today. getFullYear();
    var WeekDay=Today.g etDay();
    var SpecialDish=Dis hName(WeekDay);

    //Insert the titles of the nightly specials below;

    document.write( ""+SpecialDish) ;

    //Stop hiding -->
    </script>

    <dd>
    <script language="JavaS cript">
    <!--- Start hiding from non-JavaScript browser
    var Today=new Date();
    var ThisDay=Today.g etDate();
    var ThisMonth=Today .getMonth();
    var ThisYear=Today. getFullYear();
    var WeekDay=Today.g etDay();
    var SpecialDesc=Dis hDesc(WeekDay);


    //Insert the descriptions of the nightly specials below;

    document.write( ""+SpecialDesc) ;

    //Stop hiding -->
    </script>
  • VK

    #2
    Re: a little array query

    Remove quotes from all array declarations (what are they doing there?):
    var DName=new Array();

    Jai <dr_jaius@hotma il.com> wrote in message
    news:9f8ade96.0 309092252.3eebe fb4@posting.goo gle.com...[color=blue]
    > 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.dt d">
    > <html xmlns="http://www.w3.org/1999/xhtml">
    >
    > <html>
    > <head>
    > <title>Kelsey 's Dinner Menu</title>
    > <style>
    > body {background-image:url(tan.j pg)}
    > h3 {color:blue}
    > dt {font-weight:bold; color:green}
    > </style>
    >
    > <script language="JavaS cript">
    > <!-- 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:x-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="JavaS cript">
    > <!--- Start hiding from non-JavaScript browser
    > var Today=new Date();
    > var ThisDay=Today.g etDate();
    > var ThisMonth=Today .getMonth();
    > var ThisYear=Today. getFullYear();
    > var WeekDay=Today.g etDay();
    > var SpecialDish=Dis hName(WeekDay);
    >
    > //Insert the titles of the nightly specials below;
    >
    > document.write( ""+SpecialDish) ;
    >
    > //Stop hiding -->
    > </script>
    >
    > <dd>
    > <script language="JavaS cript">
    > <!--- Start hiding from non-JavaScript browser
    > var Today=new Date();
    > var ThisDay=Today.g etDate();
    > var ThisMonth=Today .getMonth();
    > var ThisYear=Today. getFullYear();
    > var WeekDay=Today.g etDay();
    > var SpecialDesc=Dis hDesc(WeekDay);
    >
    >
    > //Insert the descriptions of the nightly specials below;
    >
    > document.write( ""+SpecialDesc) ;
    >
    > //Stop hiding -->
    > </script>[/color]


    Comment

    • Chris Riesbeck

      #3
      Re: a little array query

      In article <9f8ade96.03090 92252.3eebefb4@ posting.google. com>,
      dr_jaius@hotmai l.com (Jai) wrote:
      [color=blue]
      > 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...[/color]
      [color=blue]
      >
      > function DishName(Day) {
      > var DName="new array()";[/color]

      you're assigning a string to DName, not making an array
      [color=blue]
      > 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";[/color]

      just say

      var DName = ["Chicken Burrito Amigo",
      "Chicken Tajine",
      ...
      "Prime Rib"];
      [color=blue]
      > return DName[Day];
      > }[/color]

      [color=blue]
      > 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";[/color]

      same comment
      [color=blue]
      > return DDesc[Day];
      > }
      >
      > // Stop hiding -->
      > </script>
      >
      >
      > </head>
      >
      > <body>
      > <center><img src="dinner.jpg ">
      > <h5><span style="font-size:x-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="JavaS cript">
      > <!--- Start hiding from non-JavaScript browser
      > var Today=new Date();
      > var ThisDay=Today.g etDate();
      > var ThisMonth=Today .getMonth();
      > var ThisYear=Today. getFullYear();
      > var WeekDay=Today.g etDay();
      > var SpecialDish=Dis hName(WeekDay);
      >
      > //Insert the titles of the nightly specials below;
      >
      > document.write( ""+SpecialDish) ;
      >
      > //Stop hiding -->
      > </script>
      >
      > <dd>
      > <script language="JavaS cript">
      > <!--- Start hiding from non-JavaScript browser
      > var Today=new Date();
      > var ThisDay=Today.g etDate();
      > var ThisMonth=Today .getMonth();
      > var ThisYear=Today. getFullYear();
      > var WeekDay=Today.g etDay();
      > var SpecialDesc=Dis hDesc(WeekDay);
      >
      >
      > //Insert the descriptions of the nightly specials below;
      >
      > document.write( ""+SpecialDesc) ;
      >
      > //Stop hiding -->
      > </script>[/color]

      Comment

      Working...