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

Dynamic Combo Box

 
Pol Appan
Ranch Hand
Posts: 144
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a JSP page where I am passing parameters to this page.
I have a dynamic combo box and in the onChange event of the combox box I am reloading the page using script.

How do I retain the same value in the combo before it's getting refreshed. Eg: If the user picks 2 from the combo, after the page get's refreshed, the selected value should be 2.

How can I do this and besides is there any method of refreshing the page using JSP method.

Any help is highly appreciated.

Thanks

Cosmos
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) pass the "2" as a parameter in the GET or POST or SESSION variable
and when building the combobox again, check each option to see if it matches the parameter you saved.

OR
2) pass the "2" as a parameter in the GET or POST or SESSION variable and after the page loads, call a javascript function that takes this parameter as an argument and sets the combobox to the correct value

OR

3)look at why you are refreshing the page. Is it possible to accomplish the same thing with Dynamic HTML or do you have to go back to the server for some reason?
 
Pol Appan
Ranch Hand
Posts: 144
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I need to refresh the page in order to load the values again from the database based on the combo box value which user selects.

Cosmos
 
Vicky Mohan
Ranch Hand
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you submit the form, you should be able to get the value selected using request.getParameter("XXXXXX") . Then can set the value in request OR session and while displaying, can loop through the collection and mark the one that matches as SELECTED.

It should not be difficult, if you can show yout logic for populating the list box, we can provide further details
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
regarding my third option:
I was suggesting that you look at dynamic combo boxes in which all the data that might populate the other combo boxes is downloaded when the page first loads and with javascript, combo boxes are repopulated with the right data after our first combobox changes.

here are some instructions:
dynamic select boxes
 
Pol Appan
Ranch Hand
Posts: 144
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, thanks for the reply, I will try that

Cosmos
[ January 21, 2005: Message edited by: Cosmos Ja ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic