Hi Jane,
You could load the strings in a javascript variable separating them by
using separators like . or something and you can query the javascript
variable using this separator.
Comments Invited!!
Thanks,
Sridhar
----- Original Message -----
From: [EMAIL PROTECTED]
Date: Thursday, April 25, 2002 11:04 pm
Subject: java script question
> This isn't exactly a struts question, but I've seen some similar
> questionsposed in this user list related to java script. What I'm
> trying to do is
> display values in a drop down list based on a value selected from
> anotherdrop down. Depending upon what is selected, I will get the
> value selected
> from the drop down, and dynamically populate the second drop down.
> I am
> using the onchange java script attribute on my struts html tag
> that fires
> an event when I select an item from the first drop down. I need to
> take the
> value selected, use it as a key, and get data from a preloaded
> array that
> has the data that I need for the second drop down. I know from reading
> through the struts user list that I need to load the array in the java
> script function to be able to get data from from it. The question
> is, how
> do I load this array in my java script function?
>
> Can the allMethodsTypes array get loaded in the java script
> function by
> referencing it as a JSP expression?
>
> Thanks,
> Jane
>
> Here's the code
>
> <%
>
> String [][] allMethodsTypes;
>
> try {
> allMethodsTypes = new String
> [methodNamesList.size()][]; for (int methodindex =
> 0; methodindex < methodNamesList.size
> (); methodindex++) {
> String method
> = (String)methodNamesList.get(methodindex);
> methTypes = bomb.getListOfMthdTypeDef(method);
> allMethodsTypes[methodindex] = new
> String[methTypes.size() + 1];
> allMethodsTypes[methodindex][0] = new
> String(method); for (int typeindex = 0;
> typeindex < methTypes.size();
> typeindex++) {
> String type =
> (String)methTypes.get(typeindex);
> allMethodsTypes[methodindex][typeindex + 1] = new
> String(type);
> }
> }
> }
> catch (Exception e) {
> System.out.println("Exception building allMethodsTypes
> array" + e);
> }
> }
> %>
>
> <select name="methodNames" size="1"
> onchange="selectMethodTypes(this.form)">
>
> <script language="JavaScript1.1">
> function selectMethodTypes(f, test)
> {
> var i;
> var x;
> if(!f) {
> return;
> }
>
> var l = f.methodNames.length;
> for (i=0; i<f.methodNames.length; i++) {
> if (f.methodNames[i].selected) {
> var s = f.methodNames[i].value;
> alert(s);
> <%
> for (x=0; x<allMethodsTypes[i][].length; x++) {
> %>
> if (s = allMethodsTypes[i][x]);
> f.methodTypes[x].value = allMethodsTypes[i][x];
> }
> }
> }
> }
> }
> </script>
>
>
>
> ****************************************
> This email message and all attachments transmitted with it are for
> the sole use of the intended recipient(s) and may contain
> confidential and
> privileged information. Please DO NOT forward this email outside
> of the recipient's Company unless expressly authorized to do so
> herein. Any
> unauthorized review, use, disclosure or distribution is
> prohibited. If you are not the intended recipient, please contact
> the sender by reply email
> and destroy all copies of the original message.
>
> Any views expressed in this email message are those of the
> individual sender except where the sender specifically states them
> to be the views of Indus
> International, Inc.
> ****************************************
>
>
> --
> To unsubscribe, e-mail: <mailto:struts-user-
> [EMAIL PROTECTED]>For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>
**************************Disclaimer************************************
Information contained in this E-MAIL being proprietary to Wipro Limited
is 'privileged' and 'confidential' and intended for use only by the
individual or entity to which it is addressed. You are notified that any
use, copying or dissemination of the information contained in the E-MAIL
in any manner whatsoever is strictly prohibited.
*****************************************************************************
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>