|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
I used the following code to create a listbox:
<%String sql = "select distinct year from yearTable order by year"; rs = stmt.executeQuery(sql);%> Year: <select size="3" name="year" MULTIPLE> <option>Select a year</option> <%while(rs.next()) { if(rs.getString(1)!=null && rs.getString(1).length() > 0){%> <option><%= rs.getString(1)%></option> <%} }%> Then I need to submit a query to MySQL according to all the selected items in the listbox. Can anyone tell me how to get all the values? request.getParameter("year") only get the first item selected. Thanks a lot. |
|
#2
|
|||
|
|||
|
getParameterValues() returns an array of all the values with the named parameter so
String[] years = req.getParameterValues("year"); will give you an array of all the "year" parameters. |
|
#3
|
|||
|
|||
|
Thanks a lot. I had been searching for an answer in an online
book but didn't get it. Thanks a lot. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Help! How to get multiple values from a listbox? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|