I also do something similar. If a textbox changed I want to set a
related hidden field to true. I wrote a javascript function that simply
knows how my html field names are going to be structured. It then can
parse out the name in order to get the index.
JavaScript:
/* Take a field and the name of another field and set the
other field to true. Assume indexed tags and mapped properties.
*/
function setStringProperty(fld, strName)
{
fname = fld.name;
first = fname.substring(0, fname.indexOf("("));
changeName = first + "(" + strName + ")";
document.forms[fld.form.name].elements[changeName].value = "1";
}
JSP:
<slogic:iterate id="component" name="ComponentsForm" property="components">
<td>
<font size="-1">Delete</font>
<shtml:text name="component" property="property(beginDate)"
indexed="true"
onchange="setStringProperty(this, 'changeFlag')" />
</td>
</slogic:iterate>
The above jsp snippet produces html that looks like:
<input type="hidden" name="clinSuppBLimit[0].property(changeFlag)"
value="0">
<input type="text" name="clinSuppBLimit[0].property(effectiveDt)"
value="09/01/2001" onchange="setStringProperty(this, 'changeFlag')">
Wilson, Les J SI-FSIA wrote:
> Hi Doug,
>
> We do something similar, but with a check box and an input field, but the
> process should be the same.
>
>
> Javascript function that enables the input field based on the checkbox
> accessed by form and index
>
> function isBudgetRequired(form, index) {
> checkBox = eval(form.elements["costElement[" + index + "].selected"]);
> budgetInput = eval(form.elements["costElement[" + index +
> "].budgetInputDisplay"]);
> if (checkBox.checked) {
> budgetInput.disabled = false;
> }
> else {
> budgetInput.disabled = true;
> }
> }
>
> JSP code snippet
> <strutslogic:iterate id="data"
> indexId="idx"
> name="ouActivityDetailForm"
> property="list">
> <tr>
> <td width="50" align="center">
> <strutshtml:checkbox property="<%= "costElement[" + idx +
> "].selected" %>"
> onclick="<%=
> "isBudgetRequired(this.form, " + idx + ")" %>" />
> </td>
> <td width="70" align="right">
> <strutsbean:define id="checked"
> name="ouActivityDetailForm"
> property="<%= "costElement[" + idx +
> "].selected" %>" />
> <strutshtml:text name="ouActivityDetailForm"
> property="<%= "costElement[" + idx +
> "].budgetInputDisplay" %>"
> size="6"
> disabled="<%=
> !((Boolean)checked).booleanValue() %>" />
> </td>
> </tr>
> </strutslogic:iterate>
>
>
> Les Wilson
>
> Shell Finance Services
> Shell International Limited, Shell Centre, London SE1 7NA, United Kingdom
>
> Tel: +44 20 7934 6463 Other Tel: +44 7974 948877
> Email: [EMAIL PROTECTED]
> Internet: http://www.shell.com
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>