Solved

retrieve data to combo box

Posted on 2003-11-28
7
351 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
password protect pdf 11 72
method inner class 6 80
java cyclic graphs 15 194
Spring MVC - sending raw charset to backend 3 174
In this article, I will show you HOW TO: Suppress Configuration Issues and Warnings Alert displayed in Summary status for ESXi 6.5 after enabling SSH or ESXi Shell.
In  today’s increasingly digital world, managed service providers (MSPs) fight for their customers’ attention, looking for ways to make them stay and purchase more services. One way to encourage that behavior is to develop a dependable brand of prod…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now