Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old July 18th, 2002, 08:18 PM
waxixi waxixi is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 16 waxixi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 21 m 31 sec
Reputation Power: 0
Unhappy Help! How to get multiple values from a listbox?

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.

Reply With Quote
  #2  
Old July 18th, 2002, 11:55 PM
jnicholas jnicholas is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 5 jnicholas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #3  
Old July 19th, 2002, 03:30 PM
waxixi waxixi is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 16 waxixi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 21 m 31 sec
Reputation Power: 0
Cool Thank you very much, Nicholas!

Thanks a lot. I had been searching for an answer in an online
book but didn't get it. Thanks a lot.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Help! How to get multiple values from a listbox?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway