Access an indexed "html:text" in "logic:iterate" from javascript

Z

Zhao

I have a loop as following

<logic:iterate id="BambooItem" name="BambooListForm"
property="bambooItemList" indexId="ctr">
<tr>
<td<html:text name="BambooItem" property="orderedNum"
indexed="true" size="4" />
....

The generated html code looks like this

<input type="text" name="BambooItem[0].orderedNum" size="4" value="1">

The challege is that it is hard to access this element from javascipt.

I tried

document.getElementsByName("BambooItem[0].orderedNum");

and it is an object but

document.getElementsByName("BambooItem[0].orderedNum").value is always
"undefined".

Since there is a "." within the name (="BambooItem[0].orderedNum") so
it is impossible to use something like

document.formname.elementname

And there is no way in "html:text" to set the id attribute of the html
element
so I can't use getElementById either...

What a Struts!

Any suggestion will be really appreciated.

thanks
 
Joined
Mar 9, 2007
Messages
1
Reaction score
0
This question is asked long ago and still not answered.

This works for me:

document.getElementsByName("BambooItem[0].orderedNum")["BambooItem[0].orderedNum"]["value"];

Wlodek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top