| Author |
populating drop-down boxes
|
jen franzke
Greenhorn
Joined: Mar 13, 2003
Posts: 6
|
|
I need to populate a drop-down list in a form with a list of Country Codes that can be obtained by calling CountryCode.getCountryCodes(), which returns a List. I am trying to use a JavaScript function to do this, but it doesn't seem to be working. I have included the code below. I am still new to JS, so please be kind. <script language="JavaScript1.2"> import jblocks.data.CountryCode; function loadCountryCodes() { countryCodes = new Array(CountryCode.getCountryCodes().size()); for (i = 0; i < countryCodes.length; i++) { countryCodes[i] = CountryCode.getCountryCodes().get(i); } document.Table2FORM.nationality.options = countryCodes; } </script> ...and right before the <form> tag... <script language="JavaScript1.2">loadCountryCodes();</script> Any help that can be offered would be much appreciated! -Jen
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
|
|
look at this and see if it helps you out any http://www.javascriptkit.com/script/cut183.shtml It shows you how to add the information to the select element.
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50673
|
|
Is this client-side or server-side JavaScript? bear
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
jen franzke
Greenhorn
Joined: Mar 13, 2003
Posts: 6
|
|
|
client-side (?). It is in the head of a .jsp file.
|
 |
sunitha reghu
Ranch Hand
Joined: Dec 12, 2002
Posts: 937
|
|
Then can u pls explain this import jblocks.data.CountryCode; r u populating the second drop down box frm a query frm db or u have the data upfront?
|
 |
jen franzke
Greenhorn
Joined: Mar 13, 2003
Posts: 6
|
|
|
jblocks.data.CountryCode is the class where the data resides. CountryCode.getCountryCodes returns a List of CountryCodes. So the data is in a class, not in a database.
|
 |
Yuriy Fuksenko
Ranch Hand
Joined: Feb 02, 2001
Posts: 411
|
|
<form> <select name=nationality> <%for (int i = 0; i < countryCodes.length; i++) {%> <option value="<%=CountryCode.getCountryCodes().get(i)%>"><%=CountryCode.getCountryCodes().get(i)%></option> <%}%> </select> </form> [ April 01, 2003: Message edited by: Yuriy Fuksenko ] [ April 01, 2003: Message edited by: Yuriy Fuksenko ]
|
 |
jen franzke
Greenhorn
Joined: Mar 13, 2003
Posts: 6
|
|
|
Thanks for the help!
|
 |
 |
|
|
subject: populating drop-down boxes
|
|
|