wood burning stoves 2.0*
The moose likes Servlets and the fly likes selection box values from database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "selection box values from database" Watch "selection box values from database" New topic
Author

selection box values from database

amit malhotra
Ranch Hand

Joined: Aug 06, 2001
Posts: 30
Hello Friends,
How can I populate my selection box values from database,please help me out
ernest fakudze
Ranch Hand

Joined: Aug 27, 2001
Posts: 216
I used the code below. It gets all the userNames from the db and populate the drop down menu. Of course remember to first initialise your Connecetions and ResultSets.
out.pritnln("<SELECT NAME =selectedCustomer>");
out.println("<OPTION VALUE =none SELECTED> Please Select A userID </OPTION>");
while(rs.next()) {
userID = rs.getString("userID");
out.println("<OPTION VALUE =\"" + userID + "\" + ");
out.println(">" + userID + "</OPTION>");
} // end while
out.println("</SELECT>");
[This message has been edited by ernest fakudze (edited October 05, 2001).]


In a time of drastic change it is the learners who inherit the future. The learned usually find themselves equipped to live in a world that no longer exists.<br />Eric Hoffer
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: selection box values from database
 
Similar Threads
Servlet getting values from a combo box
How to store a check box in DataBase??
accessing database using javascript
multi-selection list box
YUI Autocomplete with XML and JSP