Solved

Adding value to combobox

Posted on 2003-10-26
3
210 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

The business world is becoming increasingly integrated with tech. It’s not just for a select few anymore — but what about if you have a small business? It may be easier than you think to integrate technology into your small business, and it’s likely…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

828 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