This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes accessing a array in javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "accessing a array in javascript" Watch "accessing a array in javascript" New topic
Author

accessing a array in javascript

Nandu Raghu
Greenhorn

Joined: Nov 21, 2003
Posts: 12
I have a variable strarray in my form which is an array of Strings (String[])
I have this variable declared as hidden in my jsp.
The values in strarray = {"dog", "cat", rat"}- for example.
In the javascript, I am trying to access the variable as
document.forms[0].strarray[0].value.
This is giving an error on page saying that strarray.0.value is null or not an object.
However, when I print this variable in my action , it does print out the right values.
Not sure what I am missing here. Any help will be appreciated.
Thanks.
Weerawit Maneepongsawat
Ranch Hand

Joined: Apr 11, 2002
Posts: 203
Have you ever use this.

May be It's can display your value..
:roll: I don't sure it's work for you but just try. if you found any solution tell me too.


Weerawit<br />SCJP 1.4, SCWCD 1.2, SCWCD 1.4, SCBCD 1.3, SCBCD 5.0, SCMAD 1.0, SCJA 1.0, SCDJWS, SCJD, SCEA, SCDJWS 1.5
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: accessing a array in javascript