Form drop down help (null values)

Discussion in 'Javascript' started by mark, Oct 19, 2003.

  1. mark

    mark Guest

    I'm trying to make a drop down menu, when you select a few options I want it
    to do *nothing* at all, null. The following works perfectly in IE6, but it
    doesn't seem to worm in Opera 6 and IE5. When I select the valued options,
    then do nothing too. Can anyone please have a quick look @ this code and
    help me out a little :


    <form method="post" action="#">
    <select name="dropdown" onChange="javascript:if (this.value !=
    0){location.href(this.value)};">
    <option value="">Please Choose...</option>
    <option value="">~~~~~~~~~~~~~~</option>
    <option value="1.php">Oranges</option>
    <option value="2.php">Apples</option>
    <option value=""></option>
    </select>
    </form>
     
    mark, Oct 19, 2003
    #1
    1. Advertising

  2. Hi!

    Use something like

    if (this.options[this.selectedIndex].value) {location.href =
    this.options[this.selectedIndex].value}

    Here "selectedIndex" is # of selceted 'option'.

    --
    Sergey.
    http://www.takereal.com/freelance/resume.asp


    "mark" <> wrote in message
    news:bmtnn1$99i$...
    > I'm trying to make a drop down menu, when you select a few options I want

    it
    > to do *nothing* at all, null. The following works perfectly in IE6, but it
    > doesn't seem to worm in Opera 6 and IE5. When I select the valued options,
    > then do nothing too. Can anyone please have a quick look @ this code and
    > help me out a little :
    >
    >
    > <form method="post" action="#">
    > <select name="dropdown" onChange="javascript:if (this.value !=
    > 0){location.href(this.value)};">
    > <option value="">Please Choose...</option>
    > <option value="">~~~~~~~~~~~~~~</option>
    > <option value="1.php">Oranges</option>
    > <option value="2.php">Apples</option>
    > <option value=""></option>
    > </select>
    > </form>
    >
    >
    >
     
    Sergey I.Grachyov, Oct 19, 2003
    #2
    1. Advertising

  3. mark

    mark Guest

    "Sergey I.Grachyov" <> wrote in message
    news:bmtojm$g0u$...
    > Hi!
    >
    > Use something like
    >
    > if (this.options[this.selectedIndex].value) {location.href =
    > this.options[this.selectedIndex].value}


    excellent!! that works great

    many thanks

    mark
     
    mark, Oct 19, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SirPoonga
    Replies:
    2
    Views:
    780
    Ben Strackany
    Jan 7, 2005
  2. weiwei
    Replies:
    0
    Views:
    1,032
    weiwei
    Jan 5, 2007
  3. msimmons
    Replies:
    0
    Views:
    497
    msimmons
    Jul 16, 2009
  4. Replies:
    5
    Views:
    282
  5. Replies:
    3
    Views:
    296
Loading...

Share This Page