File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dependent combo

 
alex pandiyan
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
While my page loads i have 2combo boxes.
If user selects say the 1st combo,based on that the second combo should be populated.How to implement this using javascript?
For ex:1st combo while loading should contain say All sports and 2nd combo should contain all players.
If user selects say tennis in 1st combo,then 2nd combo should be populated with tennis players names alone.

Expecting ur replies in this reg!!!
 
Julian Kennedy
Ranch Hand
Posts: 823
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not continents and countries this time then?

OK, two options for you to consider:
  • you would need a separate list of the tennis players and another one for the football players, e.g. held in a JavaScript array. When the sport selection is changed you would then replace the innerHTML of the players combo with the values from the array.
  • in your players combo you could include the sport in the id field of each option, e.g. tennis players could be T1-T99 and football players could be F1-F99. That way you could filter out tennis players, for example, by removing all ids that don't being with T from the list. You'd need to keep a copy of the originals however.



  • This is what I mean by needing a relationship between the two lists as expressed in this thread you started in the JSP Forum.

    If there is a large number of sports and players this kind of thing is usually done better using the dynamic capabilities of JSP, for example.

    In my opinion, you probably wouldn't want to do it like that in the first place. That's a design issue.

    Jules
     
    Eric Pascarello
    author
    Rancher
    Posts: 15385
    6
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Double Combo Script: http://www.javascriptkit.com/script/cut183.shtml
     
    I agree. Here's the link: http://aspose.com/file-tools
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic