• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get the value selected from listbox in jsp format  RSS feed

 
tllcll
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I wanted to know how to get the value selected by user from the listbox in jsp format, later to be process in the bean file (the data was retrieve
from the database by calling the bean file). There are many dependent fields in this form and I need to get the selected value (so I can select the next data from the database based on this value as a condition,)
before user actually press the submit button.

hope you can help me out.
 
Scheepers de Bruin
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's one way of doing it (with a little javascript):

Reload the current page when the selectbox is changed (a different value is selected)

<select id="mySelect" onchange="document.forms[0].action='?newselectedindex='+this.selectedIndex; document.forms[0].submit()">

this will reload the current page, passing it the new selected index as a parameter. If you are using the <base> tag in your .jsp, you need to set the form's action to the full URL of the .jsp
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"tll cll" and "Scheepers de Bruin",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!