| Author |
How to get values from dropdown Select box in JSP
|
Maddy Tillie
Greenhorn
Joined: Jan 10, 2002
Posts: 5
|
|
Hi Gurus, I have a JSP Page in which there are drop down select boxes, which are used to search sumthing. Basically i want to get the value selected by the user from drop down select boxes in my JSP. I just wanna show the search results based on the items selected and wanna show what the user has selected from those drop down boxes.. Thanks in advance.. Regards, Maddy
|
 |
Ali Gohar
Ranch Hand
Joined: Mar 18, 2004
Posts: 572
|
|
Hi, You can do it by using getParameter method of request object. Suppose the name of the checkbox is "mycheckbox" then use following code: String value = request.getParameter("mycheckbox");
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56166
|
|
"Maddy", You'll find this forum a great place to seek help on JSP pages, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change 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 JSP Forum Bartender
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Maddy Tillie
Greenhorn
Joined: Jan 10, 2002
Posts: 5
|
|
But actually.. the form is submmited to a servlet, whcih is handling as a controller and then that servlet gets the search results and then again redirect to same JSP page.... so how do i get drop down variable in this case... thanks
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56166
|
|
|
The name of the parameter will be the name you assigned to the select element. The value of this parameter will be the selected value.
|
 |
prash po
Greenhorn
Joined: May 12, 2004
Posts: 1
|
|
Is there a way to post all the values of a select box or at least all the selected values of a select box to a JSP page. Like in a multiple selection select box how can I post all the values? I would like to read all the possible values as well as all the selected values in the JSP. As far as I know there is no way to do it. But if there is then please let me know. - P P :roll:
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56166
|
|
posted May 12, 2004 02:05 PM Is there a way to post all the values of a select box or at least all the selected values of a select box to a JSP page. Like in a multiple selection select box how can I post all the values?
The form will automatically post all selected option values. Each selected value will result in a request parameter with the name of the control and the value of the selected option. Be sure to use request.getParameterValues() when retrieving them.
|
 |
 |
|
|
subject: How to get values from dropdown Select box in JSP
|
|
|