DynaValidatorForm javascript issue

In my struts-config I have

form-bean name="dynamicArrayForm" type="...DynaValidatorForm >

<form-property name="access" type="forms.AccessRequestForm[]"/>

</form-bean>

In my jsp I have

<c:forEach var="access" items="${dynamicArrayForm.map.access}">

<tr><td><<c:out value="${access.requestedBy}"/></td>

..

<td><html:checkbox property="approve" indexed="true" name="access" onclick="chkApprove(this.form)"/>

</td>

<td><html:text property="reasonForRejection" indexed="true" name="access" value="test"/></td>

In my html I have

<input type="checkbox" name="access[0].approve" value="on" onclic="chkApprove(this.form)"></td>

<td><input type="text" name="access[0].reasonForRejection" value="test">

In my js I have

function chkApprove(formP)

{

alert(formP.access[0].reasonForRejection.value);

In my js function I get the error 'access.0' is null or not an object

Thank you for your time

[1110 byte] By [matsnaslunda] at [2007-10-3 1:50:17]
# 1

You're in a bit of a catch-22.

Names in javascript shouldn't normally contain characters like [ ] . etc, because those are the characters it uses for nesting in expressions. However these are generated by struts, so that it can use the beanutils module for form population.

try it as

formP['access[0].reasonForRejection'].value;

Doing it as a string, means that javascript will treat it all as one item (like you want it to) as opposed to splitting it up and trying to drill down into it.

Cheers,

evnafets

evnafetsa at 2007-7-14 18:48:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...