my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes Populating a combobox  dinamically from a 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 » Engineering » HTML, CSS and JavaScript
Bookmark "Populating a combobox  dinamically from a database" Watch "Populating a combobox  dinamically from a database" New topic
Author

Populating a combobox dinamically from a database

Claudia Vaz
Ranch Hand

Joined: Nov 13, 2001
Posts: 44
Hello
I have 2 combobox. When i choose the option in the first combobox (a onChange event) i want to access a database (mysql or oracle) to get the list to populate the second combobox.
I have to use a database because there are many options in the first combobox.
Does anyone knows how to do this???
Thanks
Claudia Vaz
Vijay S. Rathore
Ranch Hand

Joined: Oct 29, 2001
Posts: 449
Hi Claudia,
I think if you want to do it dynamically at front end you have to bring all the data at the front end on the html page. Store it in some array in a javascript and then on change build your drop down dynamically without going back to oracle or some database.
Vijay


SCJP, SCJD, SCWCD1.4, IBM486, IBM484, IBM 483, IBM 287, IBM141, IBM Certified Enterprise Developer - WebSphere Studio, V5.0
Author of IBM 287 Simulator Exam
Claudia Vaz
Ranch Hand

Joined: Nov 13, 2001
Posts: 44
Hello
thanks for answer.
To use your solution i would have to have 332 arrays, and some of many of these arrays would have more than 300 positions. Would it cause a problem to the jsp file( i know that the jsp compilation has a limit of 64kb)??
Claudia Vaz
Vijay S. Rathore
Ranch Hand

Joined: Oct 29, 2001
Posts: 449
Well you can concatenate the data using some special character to reduce the array size drastically and then use the split method at the javascript end to regenerate the values. Split works just like StringTokenizer in Java.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Populating a combobox dinamically from a database
 
Similar Threads
Jsp
control one JComboBox from another
ComboBox component (not JComboBox)
How to populate second combo box on the basis of first combo
ComboBox component (not JComboBox)