Solved

retrieve data to combo box

Posted on 2003-11-28
7
353 Views
Last Modified: 2010-04-01
I manage to retrieve information from my table.

while (rs.next()) {
      out.println("Division");
}

But i have no idea how can i put it (Division) into my HTML code with <select></select> statement, how you will do that?

<select>
    <option value="DD">DD</option>
    <option value="CC">CC</option>    
    <option value="BB">BB</option>    
    <option value="AA">AA</option>
    <option value="FF">FF</option>
</select>

tried this already..not sure is it correct....,and doesnt look neat.

<select>
    <% while (rs.next()) { %>
     <option value="<%= rs.getString("Division") %>"> <%= rs.getString("Division") %> </option>
<% } %>
</select>

any other alternative?
0
Comment
Question by:kotakinabalu
  • 5
  • 2
7 Comments
 
LVL 92

Expert Comment

by:objects
ID: 9841532
> and doesnt look neat.

jsp rarely does :)

what u have looks fine.
0
 
LVL 92

Expert Comment

by:objects
ID: 9841534
to make it neat you'd need to use a custom tag that knew how to generate your select from a result set.
0
 
LVL 92

Expert Comment

by:objects
ID: 9841540
the only change I'd make would be:

<select>
<%
while (rs.next())
{
   String div =   rs.getString("Division");
%>
     <option value="<%= div %>"> <%= div %> </option>
<% } %>
</select>
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:kotakinabalu
ID: 9841681
Yes, this code is working.
<select>
<%
while (rs.next())
{
  String div =   rs.getString("Division");
%>
    <option value="<%= div %>"> <%= div %> </option>
<% } %>
</select>

And i have change to taht as well. :-)

object, can share with me what i need to do if there is a duplicate data in my table and i don't want to retrieve them more than 1 time.

Division:
FF
AA
FF
CC
FF
BB
AA
FF
FF
DD
BB
DD
DD
DD

what will be my code can be?
0
 
LVL 92

Accepted Solution

by:
objects earned 200 total points
ID: 9841688
You can achieve that by changing the sql query I think so it only returns unique entries. eg.

select distinct Division from mytable
0
 

Author Comment

by:kotakinabalu
ID: 9841791
TQ object...
0
 
LVL 92

Expert Comment

by:objects
ID: 9843383
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
maven project import to eclipse problems 13 105
reflection example 3 101
by zero exception 10 41
login form jsp example 2 25
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Knowing where your website is hosted is as important as the features you receive, the monthly fee, and the support you receive. Due diligence should be done when choosing your next hosting provider.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question