selectedIndex internal variable

Discussion in 'JavaScript' started by nogal, Jun 6, 2008.

  1. #1
    Hi,

    this page is giving me 1 error on line 49
    " 'document.text1.Cookie.selectedIndex' is null or not an object"
    I tried many different options (that I know) but so far, I could not find why.

    the idea of this page is that you put your name in the field, then you select a food from the drop down list, after that, you click "click here for fortune" and in the text box will be display the name plus the cookie, finally you click on "submit order"

    View fortune here--> this line should go on the left bottom corner of the text box but no luck in position it there.

    I will appreciate any help.

    Thanks


    
    
    <HTML>
    <HEAD><title> Assign 2</title>
    
    <script type="text/javascript">
    <!-- Beginning of JavaScript -
    
    function MsgBox (textstring) {
    alert (textstring) }
    
    </script>
    </HEAD>
    <BODY>
    
    <h1><center>Chinese Food</h1>
    <h2>Fortune Restaurant</h2>
    <p><FORM name ="text1">
    Please enter your name:  <input name="text2" type="text">
    <br>
    
    Pick something from the Menu: <select name="meals" size="1">
      			<option value="Wonton Soup">Wonton Soup</option>
      			<option value="Egg Rolls">Egg Rolls</option>
      			<option value="Chow Mein">Chow Mein</option>
     			<option value="Xang Su Ya">Xang Su Ya</option>
    			<option value="Dou Ban Yu">Dou Ban Yu</option>
    			</select><br><br>
    
    </center>
    </FORM>
    
    <script type="text/javascript">
    var Cookie = new Array(5);
    Cookie[0] = "An opportunity will knock on your door";
    Cookie[1] = "Friendship is more than a hand";
    Cookie[2] = "Be thankfull everyday";
    Cookie[3] = "Be impecable with your words";
    Cookie[4] = "Give always the best of you";
    
    var indexCookie=null;
    
    function showcookies() {
    
    myIndexCookie = document.text1.Cookie.selectedIndex;
    document.text1.cookies.value = cookie[document.text1.text2.value];
    }
    
    </script>
    <center>
    
    <p><input type="button" value="Click here for Fortune" onClick="showcookies();"></p>
    
    <p>View fortune here--><textarea name="cookies" rows="6" cols="40"> </textarea> </p>
    
    <p><input type="button" value="Submit Order" onClick="showcookies();"> </p>
    
    
    </center>
    </SCRIPT>
    </BODY>
    </HTML>
    
    
    Code (markup):
     
    nogal, Jun 6, 2008 IP
  2. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
    #2
    change

    name ="text1"

    to
    name="text1"
     
    crath, Jun 8, 2008 IP
  3. nogal

    nogal Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks crath. I got it. now it is working fine.

    Thanks for your support and will see you next time.
     
    nogal, Jun 8, 2008 IP