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 4 of 4

Thread: Double Combo

  1. #1
    New Coder
    Join Date
    Feb 2003
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Double Combo

    I have a problem with a scritp. You must know that this script is call Double Combo. What's the problem?, when i select in the first combo box an option and then select in the second combo box an obtion then i hit GO and then if i go BACK in the firs combo box is my option but in the second combo is not the obtions for it.
    I have try to be more precise but this problem is wierd. This script is from this site.
    Thanks!

  • #2
    Regular Coder
    Join Date
    Dec 2002
    Location
    a bit west of pittsburgh
    Posts
    236
    Thanks
    1
    Thanked 0 Times in 0 Posts
    put the function you used to set the options for the second combo box in the onLoad for your <body> tag

  • #3
    New Coder
    Join Date
    Feb 2003
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have try this but, not working. I have use the function redirect(x) (see the script). What function i must use? If i use in stead of x, this.options.selectedIndex is an error because is not an object.
    Please help me if you can.
    Thanks!!! This is the script:

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

    <script>
    <!--
    var groups=document.doublecombo.example.options.length
    var group=new Array(groups)
    for (i=0; i<groups; i++)
    group[i]=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")

    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[i]=new Option(group[x][i].text,group[x][i].value)
    }
    temp.options[0].selected=true
    }

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

    </form>

  • #4
    New Coder
    Join Date
    Feb 2003
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hei !!! I have find it. How stupid i am. The function for onLoad is
    redirect(doublecombo.example.options.selectedIndex) this is an object. Thanks a lot man!!!


  •  

    Posting Permissions

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