Help required using "Doublecombo" script

Discussion in 'Javascript' started by skinnybloke, Apr 16, 2004.

  1. skinnybloke

    skinnybloke Guest

    Hi - I have installed the doublecombo script from "Javascript Kit"
    which populates a second drop down box based on the selection in the
    first drop down box.

    What I want it to do extra is that when it goes to the target page it
    displays in the 1st dropdownbox the choice made, and in the 2nd
    dropdown box the options for that choice.

    My javascript is well rusty and I've played around with this using
    cookies etc. but cannot get it too work.

    Any help would be greatly appreciated. The double combo script is:

    <form name="doublecombo">
    <p><select name="example" size="1"
    onChange="redirect(this.options.selectedIndex)">
    <option>Technology Sites</option>
    <option>News Sites</option>
    <option>Search Engines</option>
    </select>
    <select name="stage2" size="1">
    <option value="http://javascriptkit.com">JavaScript Kit</option>
    <option value="http://www.news.com">News.com</option>
    <option value="http://www.wired.com">Wired News</option>
    </select>
    <input type="button" name="test" value="Go!"
    onClick="go()">
    </p>

    <script>
    <!--

    /*
    Double Combo Script Credit
    By JavaScript Kit (www.javascriptkit.com)
    Over 200+ free JavaScripts here!
    */

    var groups=document.doublecombo.example.options.length
    var group=new Array(groups)
    for (i=0; i<groups; i++)
    group=new Array()

    group[0][0]=new Option("JavaScript Kit","http://javascriptkit.com")
    group[0][1]=new Option("News.com","http://www.news.com")
    group[0][2]=new Option("Wired News","http://www.wired.com")

    group[1][0]=new Option("CNN","http://www.cnn.com")
    group[1][1]=new Option("ABC News","http://www.abcnews.com")

    group[2][0]=new Option("Hotbot","http://www.hotbot.com")
    group[2][1]=new Option("Infoseek","http://www.infoseek.com")
    group[2][2]=new Option("Excite","http://www.excite.com")
    group[2][3]=new Option("Lycos","http://www.lycos.com")

    var temp=document.doublecombo.stage2

    function redirect(x){
    for (m=temp.options.length-1;m>0;m--)
    temp.options[m]=null
    for (i=0;i<group[x].length;i++){
    temp.options=new Option(group[x].text,group[x].value)
    }
    temp.options[0].selected=true
    }

    function go(){
    location=temp.options[temp.selectedIndex].value
    }
    //-->
    </script>

    </form>


    TIA
    skinnybloke, Apr 16, 2004
    #1
    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. Just D.
    Replies:
    0
    Views:
    432
    Just D.
    Mar 10, 2006
  2. Mike Blackett
    Replies:
    1
    Views:
    71
    Mike Blackett
    Jul 24, 2003
  3. Brian
    Replies:
    0
    Views:
    62
    Brian
    Sep 16, 2003
  4. Randell D.

    Using <script src> tag, is type required?

    Randell D., Dec 24, 2003, in forum: Javascript
    Replies:
    4
    Views:
    117
    Randell D.
    Dec 25, 2003
  5. skinnybloke

    Help required modifying Doublecombo script

    skinnybloke, Apr 20, 2004, in forum: Javascript
    Replies:
    0
    Views:
    78
    skinnybloke
    Apr 20, 2004
Loading...

Share This Page