Results 1 to 4 of 4

Thread: Programming Go Button on Chained Select Menu

  1. #1
    Join Date
    Dec 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Programming Go Button on Chained Select Menu

    1) Script Title: Chained Select Menu

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/chainedmenu/

    3) Describe problem:

    I am new to programming and I have no problem googling and learning, but I just need help being pointed in the right direction because I have a feeling I am not heading the right way.

    I am using the Chained Select Menu and I read through it and set up my menu's to work the way I want them, but the default way the "Go" button is programed is to have a popup error type box display the result.

    so in the HTML form that I paste into the website, I changed the input type from "button" to "submit". I still get the button popup, but now it redirects to a new url.

    Example:

    I select Car Sites>Regular Cars>Ford from the menu, I hit go. It displays a popup with "www.ford.com" and after I hit "Ok" it redirects the site to this:

    Code:
    http://www.domain.com/?firstlevel=&secondlevel=&thirdlevel=http%3A%2F%2Fwww.ford.com
    Now how do I A) Remove the popup message B) direct the website correctly based on the selected items in the menus.

    The instructions are very helpful and detailed on how to modify the menus, but not the "Go" button.

    Any help would be appreciated.

    -Brad

  2. #2
    Join Date
    Dec 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Here is the sample html code:

    Code:
    <html>
    
    <head>
    <title>Chained Selects</title>
    <script language="javascript" src="chainedmenu.js">
    
    /***********************************************
    * Chained Select Menu- By Xin Yang (http://www.yxscripts.com/) & Dynamic Drive (http://dynamicdrive.com)
    * Script featured on/available at http://www.dynamicdrive.com/
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
    * This notice must stay intact for legal use!
    ***********************************************/
    
    </script>
    <script language="javascript" src="config.js"></script>
    
    </head>
    
    <body onload="initListGroup('chainedmenu', document.listmenu0.firstlevel, document.listmenu0.secondlevel, document.listmenu0.thirdlevel, 'savestate')">
    
    <form name="listmenu0">
    <table align="center"><tr>
    <td><select name="firstlevel" style="width:180px;"></select></td>
    <td><select name="secondlevel" style="width:160px;"></select></td>
    <td><select name="thirdlevel" style="width:160px;"></select></td>
    <td><input type="button" value="Go" onclick="goListGroup(document.listmenu0.firstlevel, document.listmenu0.secondlevel, document.listmenu0.thirdlevel)">
     <input type="button" value="Reset" onclick="resetListGroup('chainedmenu')">
    </tr></table>
    </form>
    
    <h3>Notes</h3>
    <ul>
    <li>An arbitrary string ("savestate") is passed in as the last argument of function initListGroup() inside this page, "sample.html", enabling the session-only cookie persistent feature. What this means is that the script will save and load the last state of the chained Selection lists when you reload or return to this page. See the documentation in chainedmenu.html for more info.</li>
    <li>Disable empty lists feature is enabled, so empty lists are disabled (grayed out).</li>
    </ul>
    
    <p align="center">Dynamic Drive- <a href="http://www.dynamicdrive.com/dynamicindex1/chainedmenu/">Chained Select Menu</a></p>
    
    </body>
    
    </html>

  3. #3
    Join Date
    Dec 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I figured it out....for future reference if anyone else has this problem, this is what I did....

    In the chainedmenu.js....

    Change this:

    Code:
    ///// DynamicDrive.com added function/////////////
    
    var onclickaction="alert"
    
    function goListGroup(){
    for (i=arguments.length-1;i>=0; i--){
    if (arguments[i].selectedIndex!=-1){
    var selectedOptionvalue=arguments[i].options[arguments[i].selectedIndex].value
    if (selectedOptionvalue!=""){
    if (onclickaction=="alert")
    alert(selectedOptionvalue)
    else if (newwindow==1)
    window.open(selectedOptionvalue)
    else
    window.location=selectedOptionvalue
    break
    }
    }
    }
    }
    
    ///// END DynamicDrive.com added function//////
    To this:

    Code:
    ///// DynamicDrive.com added function/////////////
    
    var onclickaction="goto"
    
    function goListGroup(){
    for (i=arguments.length-1;i>=0; i--){
    if (arguments[i].selectedIndex!=-1){
    var selectedOptionvalue=arguments[i].options[arguments[i].selectedIndex].value
    if (selectedOptionvalue!=""){
    if (onclickaction=="goto")
    alert(selectedOptionvalue)
    else if (newwindow==1)
    window.open(selectedOptionvalue)
    else
    window.location=selectedOptionvalue
    break
    }
    }
    }
    }
    
    ///// END DynamicDrive.com added function//////
    Basicly, change anything that says "alert" to "goto"

    Maybe someone can update the instructions with this info for n00bs like me

  4. #4
    Join Date
    Jan 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You star! - thank you.

    I had the same problem, and found your answer after a search. Agree with the comments & thankful for those who produced the scripts in the first place!

Bookmarks

Posting Permissions

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