www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 23

Thread: Drop Down Menu

Hybrid View

  1. #1
    Join Date
    Apr 2003
    Posts
    6

    Unhappy Drop Down Menu

    I am having a problem getting my drop down menu to work!

    This what I want it to do:

    When I click on Randy and June I want it to go to that link.


    I am generating the code from here:

    http://javascript.internet.com/gener...down-menu.html


    This is the code I get from the generater:

    <form name="jump">
    <select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO">
    <option value="http://www.geocities.com/flower9980/parents.html">Randy and June</option>
    <option value="http://www.geocities.com/flower9980/junemicky.html">June and Micky</option>
    <option value="http://www.geocities.com/flower9980/mindydan.html">Mindy and Dan</option>
    <option value="http://www.geocities.com/flower9980/cathymichael.html">Cathy and Michael</option>
    <option value="http://www.geocities.com/flower9980/me.html">Melissa</option>
    <option value="http://www.geocities.com/flower9980/mejasonpics.html">Melissa and Jason</option>
    <option value="http://www.geocities.com/flower9980/bubba.html">Bubba</option>
    <option value="http://www.geocities.com/flower9980/rampey.html">Rampey</option>
    <option value="http://www.geocities.com/flower9980/zimmerman.html">Zimmerman</option>
    </select>
    </form>


    The menu show up on my webpage but it doesn't go to that link. Here is my webpage if you want to look at it! http://www.geocities.com/flower8099/family.html Please help!! I tired and tired!

    flower8099@yahoo.com

  2. #2
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    <select name="menu" onChange="location=this.selectedIndex.value" value="GO">
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  3. #3
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    2,653
    Chagne this line
    onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;

    with this
    onChange="window.location.href=document.jump.menu.options[document.jump.menu.selectedIndex].value;

  4. #4
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Khalid, the error was: "document.jump.menu" is null or not an object... I always like to shorten the code with "this."
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  5. #5
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    The code you posted is fine, too. You must have a problem elsewhere, if it is not working for you.

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  6. #6
    Join Date
    Apr 2003
    Posts
    6

    Unhappy Extra info

    I just found out this:

    If I use the code by itself it works, but I want to add two more drop down menus under it. And when I do that, that is when it doesn't work. Am I messing anything?

    Here is what I have:

    <font size=2 face="Verdana,Arial">
    Family:
    </font>
    <form name="jump">
    <select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO">
    <option value="http://www.geocities.com/flower9980/parents.html">Randy and June</option>
    <option value="http://www.geocities.com/flower9980/junemicky.html">June and Micky</option>
    <option value="http://www.geocities.com/flower9980/mindydan.html">Mindy and Dan</option>
    <option value="http://www.geocities.com/flower9980/cathymichael.html">Cathy and Michael</option>
    <option value="http://www.geocities.com/flower9980/me.html">Melissa</option>
    <option value="http://www.geocities.com/flower9980/mejasonpics.html">Melissa and Jason</option>
    <option value="http://www.geocities.com/flower9980/bubba.html">Bubba</option>
    <option value="http://www.geocities.com/flower9980/rampey.html">Rampey</option>
    <option value="http://www.geocities.com/flower9980/zimmerman.html">Zimmerman</option>
    </select>
    </form>

    <font size=2 face="Verdana,Arial">
    Friends:
    </font>
    <form name="jump">
    <select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO">
    <option >Go to....
    <option value="http://www.geocities.com/flower9980/highschool.html">High School</option>
    <option value="http://www.geocities.com/flower9980/church.html">Church</option>
    <option value="http://www.geocities.com/flower9980/college.html">College</option>
    </select>
    </form>

    <font size=2 face="Verdana,Arial">
    Cats:
    </font>
    <form name="jump">
    <select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO">
    <option >Go to.... </option>
    <option value="http://www.geocities.com/flower9980/callie.html">Kitty Callie</option>
    <option value="http://www.geocities.com/flower9980/frisky.html">Frisky</option>
    <option value="http://www.geocities.com/flower9980/jasper.html">Jasper</option>
    </select>
    </form>

  7. #7
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    That's where your problem is!

    Try changing the select box name of each select box. Otherwise it'll cause an error. That's why I use "this" in my code...
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  8. #8
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    The code that you posted above will not work, though, Jona. You need to do it like this:

    <select name="menu" onChange="location=this.options[this.selectedIndex].value;" value="GO">

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  9. #9
    Join Date
    Apr 2003
    Posts
    6

    extra info2

    I changed the names of each select to
    menu1
    menu2
    menu3

    that didn't work.. but it is a good idea!

  10. #10
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Oh yah, Pyro, my mistake. But doesn't location=this.options.selectedIndex work as well? I'm pretty sure it does.
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  11. #11
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413

    Re: extra info2

    Originally posted by flower8099
    I changed the names of each select to
    menu1
    menu2
    menu3

    that didn't work.. but it is a good idea!
    You don't just change their names. I suggested (twice) to use "this" instead. But you also have to change ever occurence of the name.
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  12. #12
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Try adding this to each of your select tags, in replacement of your current onChange functions:
    onChange="location=this.options[this.selectedIndex].value;"

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  13. #13
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Originally posted by Jona
    But doesn't location=this.options.selectedIndex work as well?
    Nope.

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  14. #14
    Join Date
    Apr 2003
    Posts
    6

    Thumbs up Extra info3

    AWESOME!!! it worked.. thank you guys so so so so very much!! This is my first time working with java script!! And now it will be easier with the help of all you guys!! Thanks again!!

  15. #15
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Originally posted by pyro
    Nope.
    Hmmmmm..... I thought it did. I'm pretty sure it did, as a matter of fact. But then, I'm using IE... So there's no telling. Anyways, thanks for clearing me up, Pyro.
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles