• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

dependent combo  RSS feed

Posts: 10
  • 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!!!
Ranch Hand
Posts: 823
  • 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.

    Posts: 15385
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Double Combo Script: http://www.javascriptkit.com/script/cut183.shtml
    Look ma! I'm selling my stuff!
    global solutions you can do at home or in your backyard
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!