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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with double combo

    I used the example of a double combo script (http://wsabstract.com/script/cut183.shtml ) to make my own. I only changed a few things; mostly renamed the names of the form and the select boxes and removed the go function as I don't need that.

    Anyway, my script looks like this and it works perfectly:

    Code:
    <script>
    <!--
    
    var groups=document.form.category.options.length
    var group=new Array(groups)
    for (i=0; i<groups; i++)
    group[i]=new Array()
    
    group[0][0]=new Option("<-- No subcategory selected-->","-1")
    
    group[1][0]=new Option("JavaScript Kit","http://javascriptkit.com")
    group[1][1]=new Option("News.com","http://www.news.com")
    group[1][2]=new Option("Wired News","http://www.wired.com")
    
    group[2][0]=new Option("CNN","http://www.cnn.com")
    group[2][1]=new Option("ABC News","http://www.abcnews.com")
    
    group[3][0]=new Option("Hotbot","http://www.hotbot.com")
    group[3][1]=new Option("Infoseek","http://www.infoseek.com")
    group[3][2]=new Option("Excite","http://www.excite.com")
    group[3][3]=new Option("Lycos","http://www.lycos.com")
    
    var temp=document.form.subcategory
    
    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
    }
    
    //-->
    </script>
    However, when I change the options to my own options it doesn't work. That's all I've changed and I can't see what's wrong.

    Code:
    <script>
    <!--
    
    var groups=document.form.category.options.length
    var group=new Array(groups)
    for (i=0; i<groups; i++)
    group[i]=new Array()
    
    group[0][0]=new Option("<-- No subcategory selected-->","-1")
    
    group[1][0]=new option("Star Wars","1")
    group[1][1]=new option("Indiana Jones","2")
    
    group[2][0]=new option("Sam & Max","3")
    group[2][1]=new option("RollerCoaster Tycoon","4")
    
    group[4][0]=new option("Pirates","5")
    
    var temp=document.form.subcategory
    
    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
    }
    
    //-->
    </script>
    Any idea as to why the latter doesn't work?
    Last edited by Dalixam; 03-21-2004 at 06:41 PM.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    What is the number refering to?


    ("Star Wars","1 ")

  • #3
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Does that matter? It's just the value for that selection in the drop down menu. Right now it refers to nothing, it's just an example.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Why did you skip group[3]?
    Code:
    ...
    group[2][1]=new option("RollerCoaster Tycoon","4")
    
    group[4][0]=new option("Pirates","5")
    ...
    Also, you need to change option to Option.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The group 3 thing was not the problem, but it was that I had used o instead of O. I can't believe I missed that. Thanks for pointing it out


  •  

    Posting Permissions

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