Solved

Adding value to combobox

Posted on 2003-10-26
3
202 Views
Last Modified: 2010-04-01
Hi,

I have a combo box:

Color
<select name="col">
<option value='red'>Red</option>
<option value='blue'>Blue</option>
<option value='white'>White</option>
<option value='green'>Green</option>
<option value='black'>Black</option>
</select>


Values are set at the combo box using the option

How do i get it to get value from database,

for example i have a table
called Color with colorid and description.
How do i do it so that i could add new colors and it gets added to combo.And if i delete the value from database, it gets deleted from combo as well

Thanks
0
Comment
Question by:Jasbir21
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
kennethxu earned 100 total points
ID: 9622885
I asume you familiar with JDBC programming and know how to get a resultset from database, and there is what you need to do in your jsp page:
<%
   // jdbc code to get ResultSet from database:
   ResultSet rs = stmt.executeQuery( "select colorid, colordesc from color" );
%>
<select name="col">
<% while( rs.next() ) { %>
<option value='<%=rs.getString(1)%>'><%=rs.getString(2)%></option>
<% } %>
</select>
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9622919
in case you need information on jdbc programming:
http://java.sun.com/docs/books/tutorial/jdbc/basics/
http://www.javaolympus.com/freebooks/FreeJDBCBooks.jsp

let us know if you have further enquires.
0
 

Author Comment

by:Jasbir21
ID: 9624456
Thank you very much.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

13 Experts available now in Live!

Get 1:1 Help Now