Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

2 Select Box`s on one page, second needs to load dynamically

 
Derick Potgieter
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I`m struggling with an problem on one of my pages, to do with selects.

I need to display a list of countries around the world in a drop down, then when the user selects the first country
I need to populate the second drop down with the towns under that country.
All this data comes from my DB2 database.

This has to be on one page, as I only need the ID from the second drop down to write back to my database.
Now I don�t have a problem to populate the first select, but how do you handle the second if I needs to be dynamically
Loaded from the database?

Thanks, any help will be appreciated?

Rgds
Derick
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are going to need to do a post back on the server with an onchange event on the server. Using jsp?

Eric
 
Derick Potgieter
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, sorry this buggles my mind a bit. Do you mabe have some code that could help me??

thanks
 
Eric Pascarello
author
Rancher
Posts: 15385
6
 
Derick Potgieter
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thanks

I am using JSP`s, with struts.

I cant believe that it takes that much effort jsut to get the second select working.

Is there no other way to go though this process using some of struts`s features??

Thanks
Derick
 
Eugene Lucash
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can write a some simple solution.
Imagine a real code instead of pseudo-pseudo-java-code

In POJO's


In Action



In JSP



I hope this give you some insight

[ February 19, 2005: Message edited by: Eugene Lucash ]

[ February 19, 2005: Message edited by: Eugene Lucash ]

[ February 19, 2005: Message edited by: Eugene Lucash ]

[ February 19, 2005: Message edited by: Eugene Lucash ]

[ February 19, 2005: Message edited by: Eugene Lucash ]
[ February 19, 2005: Message edited by: Eugene Lucash ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a JavaScript solution if you want to avoid the post back. What you would have to do is write all of the possible items in JavaScript arrays. If you want this, you can search on google for JavaScript Double combo and you should find some results.

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic