Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Only my first JS dropdown menu is working...

    I found this simple DD code, that allows a user to select an option and not need a submit button. I have 6 DD menus, but only the first is working. I have separated all functions into separate external .js files, and have a call to all of them in the head of my page. You can view the source code here http://www.kidsfirstweecycling.com ,it is the splash page.

    Since I have 6 dd menus, I created 6 individual .js files. They all read the same with only the "city name" being changed throughout. In the example below the city name is "corona"... in the other 5 files it is changed to the other city names.

    Code:
    function coronanav()
       {
       var w = document.coronaform.coronalist.selectedIndex;
       var url_add = document.coronaform.coronalist.options[w].value;
       window.location.href = url_add;
       }

    I think it must be something simple, but since I am not fluent, I must be missing it.

    Thanks!

  • #2
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    It's because your function is only effecting one form element. You'll need something more like this
    Code:
    function coronanav(el)
       {
       var w = document.coronaform.el.selectedIndex;
       var url_add = document.coronaform.el.options[w].value;
       window.location.href = url_add;
       }
    where "el" is the name of the form element that you want it to effect you would call it like this
    Code:
    coronanav(element_name)// this would replace your old function

  • Users who have thanked ninnypants for this post:

    clarkj03 (08-23-2008)


  •  

    Posting Permissions

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