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

x
?
Solved

Adding value to combobox

Posted on 2003-10-26
3
Medium Priority
?
213 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
[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
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
kennethxu earned 400 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Files go missing when using DFS (Distributed File System) Replication and how to recover them and fix it.
What we learned in Webroot's webinar on multi-vector protection.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

688 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