You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Fabiano de O. Lucchese" <fl...@yahoo.com> on 2003/06/25 20:52:49 UTC

Indexed properties and JavaScript

Hi All,

I've been trying to develop a Struts based web site
and got stuck by the following problem: I have defined
a form bean that contains indexed properties; thus,
I'm supposed to use squared brackets "[x]" to refer to
the individual elements of each of these "array-like
properties" into my HTML/JSP page; on the other hand,
I also had to embbed some javascript code in this page
in order to enlighten the server-side processing. The
problem is that I just can't use javascript code along
with "array-like properties" because the brackets used
by them seem to conflict with the javascript syntax.

The following sample code reproduces this problem:

<html>
        <head>
                <title>test</title>
        </head>

        <body>
                <form action="/test" method="GET"
name="testForm">
                        <input type="text"
name="att[0]">
                        <input type="button"
onclick="alert(document.testForm.att[0])"
value="test">
                </form>
        </body>
</html>

and the error message is something like:
"document.testForm.att.0 is null or is not an object".

One should notice that when the index reference [0] is
deleted, the page works fine.

Does anyone here has any experience with this problem
?

Thanks in advance.

FLu-X


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org