Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Combobox Script Required

 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I have a situation in which I have a combo box whose values are pulled from a database. Now if I select the first value in the combobox, then it should pull the corresponding values in another combo box.

A more practical view of this would be like this, Imagine I have some questions stored in questions table and the questions will have choices stored in choices table with each choice having the corresponding question id. Now I want to display them in a jsp page in the form of a combo box like I mentioned above. How can I do this? Any help appreciated.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is normally called a double combo. You can either do it the classic way of posting back the form onchange of the first dropdown list OR you can look into the nifty Ajax solution. The forum and ranch are full of examples on how to do this.

Eric
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll try to find them. Thanks!
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried looking by doing a search, but no satisfactory results I could get. I'm missing out some minute details on the examples spread across over the web. Does anyone here have some links...please I'm in desperate need of it.

Thanks in advance!
 
John Mikhail
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GWT supports the notion of RPC calls, which are asynchronous calls to the server. In your GWT code, you invoke the RPC call, passing in a callback class that would get invoked upon completion of the call.

So in your particular case, you would listen for a select event, at which point you invoke the RPC call. Then in the callback handler (where you would have passed back any results from say a db query, etc), you populate your second listbox. All asynchronously, no need to do any post backs or anything. GWT handles all that for you very nicely.

You can find a starting point here: http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.RemoteProcedureCalls.html

Hope this helps.

John
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no indication in this topic that the OP is using GWT.
 
John Mikhail
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very true...I saw the previous GWT posts by Jothi and just assumed. My apologies.
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any help guys...??
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's an example I found with a google search on "dependent dropdowns ajax".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic