*
The moose likes HTML, CSS and JavaScript and the fly likes a question about a drop-down menu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "a question about a drop-down menu" Watch "a question about a drop-down menu" New topic
Author

a question about a drop-down menu

chang nanny
Greenhorn

Joined: Feb 15, 2004
Posts: 14
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Feb 15, 2004
Posts: 14
Hello,
Could you give me an example?
Thank you.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
http://www.javascriptkit.com/script/cut183.shtml
chang nanny
Greenhorn

Joined: Feb 15, 2004
Posts: 14
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

Joined: Feb 02, 2001
Posts: 413
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>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a question about a drop-down menu