Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

retrieve data to combo box

Posted on 2003-11-28
7
Medium Priority
?
367 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 800 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Are you an Exchange administrator employed with an organization? And, have you encountered a corrupt Exchange database due to which you are not able to open its EDB file. This article will explain all the steps to repair corrupt Exchange database.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

715 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