Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a question about a drop-down menu

 
chang nanny
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have two drop-down menus.
As I select the option form first menu, i query from db according to the option.
And the recordset are second menu's option values.
I use submit() method to reload the page and change the second menu.
Is there any other way to do?
Thank you.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes,
When the page loads the first time you can have all of theoptions written out in arrays and use a premade javascript double combo script to fill in the second drop down.
THis would not require the form to be submitted to get the options and will be faster for the user in most cases.
Eric
 
chang nanny
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Could you give me an example?
Thank you.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
 
chang nanny
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Thank you.
But my second combo box option value query from db(server-side).
my question is how should i put data from db into javascript array?
 
Yuriy Fuksenko
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends
This is a jsp example:
<%
String[] values = myClass.getValuesFromDB();
%>
<script>
var jsArray = new Array();
<% for(int i=0;values!=null && i<values.length;i++){%>
//this line assumes you can not get '\n' or double quotes from db
//if so you have to escape them.
jsArray[<%=i%>]= "<%=values[i]%>";
<%}%>
</script>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic