The moose likes Struts and the fly likes DynaValidatorForm javascript issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "DynaValidatorForm javascript issue " Watch "DynaValidatorForm javascript issue " New topic

DynaValidatorForm javascript issue

john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
In my struts-config I have

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

In my jsp I have

<c:forEach var="access" items="${}">
<tr><td><<c ut value="${access.requestedBy}"/></td>
<td><html:checkbox property="approve" indexed="true" name="access" oncli="chkApprove(this.form)"/>
<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)


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

Thank you for your time
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
In JavaScript, any time an element name contains characters such as "[" or "." that have meaning in JavaScript, you can't access the element by just naming it as in myForm.myProperty[0].foo. You have to be creative and think of a way to treat the name as a string. For example:




Consultant, Sima Solutions
I agree. Here's the link:
subject: DynaValidatorForm javascript issue
It's not a secret anymore!