Apologies if anyone had problems with the last version I sent - it had a
zipped attachement of an html file that was blocked by a few servers.
Les
-----Original Message-----
From: Wilson, Les J SI-FSIA
Sent: 26 April 2002 14:25
To: Struts Users Mailing List
Subject: RE: java script question
Hi Jane,
I've done something similar, but use a form with hidden fields that gets
created at application initialisation and stored in the servletcontext.
I use the following to include the form in a jsp
<strutsbean:write name="<%= Constants.PRODUCT_LINE_FORM %>"
scope="application"
filter="false" />
The HTML code below reads the corresponding hidden field when the first
choice is changed, parses its value and populates the second drop down.
Hope that helps.
<html>
<head>
<script language="javascript">
// Changes the product line based on the business line selected
function setProductLine ( formName, choice, target )
{
var count=1;
var val;
var businessLine = eval ('document.forms["' + formName + '"].elements["'
+ choice + '"]');
var id = businessLine.options[businessLine.selectedIndex].value;
var productLine = eval ('document.forms["' + formName + '"].elements["'
+ target + '"];');
productLine.options.length = 0;
productLine.options[0] = new Option( "All Entries", "0", true, true );
if (( id.charAt(0) != "0" ) && ( id.length > 0 ) ) {
var bl = "BL_" + id;
var field = document.forms["productLines"].elements["BL_" + id];
if(field != null) {
val = field.value;
if(val != null) {
var arrayList = val.split("|");
items = arrayList.length;
for ( var i=0; i<items; i++) {
var id = arrayList[i];
var name = arrayList[i+1];
productLine.options[count] = new Option( name, id );
count++;
i++;
}
}
}
}
}
</script>
<title>
Test Drop downs
</title>
</head>
<body class="content" onload="">
<form name="activityCriteriaForm" method="POST"
action="/FS-APPS/eFinancePeople/activityList.do">
<table cellpadding="0" cellspacing="0">
<tr>
<td width="170">
Choose Entry
</td>
<td>
<select name="businesslineid" size="1"
onchange="setProductLine('activityCriteriaForm','businesslineid','productlin
eid');">
<option value="0" selected="selected"><NOT
SPECIFIED></option>
<option value="1">Entry 1</option>
<option value="2">Entry 2</option>
<option value="3">Entry 3</option>
<option value="4">Entry 4</option>
</td>
<td class="detailLabel" width="170">
Other Options
</td>
<td>
<select name="productlineid" size="1"><option
value=""></option></select>
</td>
</tr>
</table>
</form>
<form name="productLines"><input type="hidden" name="BL_1"
value="115|Australia|45|Houston|47|London"><input type="hidden" name="BL_2"
value="106|Asia Pacific|104|Houston|102|London|117|Switzerland"><input
type="hidden" name="BL_3" value="121|East Zone Region Team|8|European Region
Team"><input type="hidden" name="BL_4" value="43|Accounting Flows|22|AF
2|113|Houston ABC|56|New Business"></form>
</body>
</html>
Les
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 25 April 2002 23:04
To: Struts User mailing list
Subject: java script question
This isn't exactly a struts question, but I've seen some similar questions
posed 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 another
drop 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
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>