Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Populating a combobox dinamically from a database

 
Claudia Vaz
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Claudia Vaz
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic