aspose file tools*
The moose likes JDBC and the fly likes Populating <select> with values from a database. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Populating <select> with values from a database." Watch "Populating <select> with values from a database." New topic
Author

Populating <select> with values from a database.

abhiavi kumar
Greenhorn

Joined: Mar 13, 2013
Posts: 20
Hello there,

I have a registration form, and I'm looking to populate a <select> with the values retrieved from the column of a database. How do I go about achieving this ? Here is an example for better detail.

The options of a <select> drop down list is populated from a certain column called "Manuid" which is located in a table called "Manu".

assuming the values under "Manuid" are "Sam" "Mike" "Arnie" and "Joe", I want all these names to appear when I click on the drop-down button. This is not a "fixed" column, meaning I will keep adding new names as well as deleting under "Manuid", which would mean a dynamic drop down list that changes every time I change the DB. How would I be able to do this? I'm only looking at Javascript and JDBC to achieve this... is it possible?
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30764
    
156

You definitely need more than JavaScript and JDBC. In particular, you at least need Servlets (and more Java classes)

When you say it changes every time you change the database, do you mean on the existing already rendered page? If so, you need AJAX. Otherwise, you can just look up the values in that column when loading the registration forum.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Populating <select> with values from a database.