my dog learned polymorphism*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "DynaValidatorForm javascript issue " Watch "DynaValidatorForm javascript issue " New topic
Author

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[]"/>
</form-bean>

In my jsp I have

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

myForm.item("myProperty[0].foo")

or

document.getElementsByName("myProperty[0].foo")[0]


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DynaValidatorForm javascript issue
 
Similar Threads
Passing jstl to javascript function
javascript div issues
retrieve value of a field
text field validation
Retrieving radio selection & checkbox selection from a DynaForm