wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Combobox Script Required Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Combobox Script Required" Watch "Combobox Script Required" New topic
Author

Combobox Script Required

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9389
    
    2

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.


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Sep 26, 2006
Posts: 9389
    
    2

I'll try to find them. Thanks!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9389
    
    2

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

Joined: Jun 03, 2005
Posts: 20
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

Joined: Jan 10, 2002
Posts: 61237
    
  66

There is no indication in this topic that the OP is using GWT.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
John Mikhail
Greenhorn

Joined: Jun 03, 2005
Posts: 20
Very true...I saw the previous GWT posts by Jothi and just assumed. My apologies.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9389
    
    2

Any help guys...??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61237
    
  66

Here's an example I found with a google search on "dependent dropdowns ajax".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Combobox Script Required