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

Discussion in 'Java' started by Zhao, Sep 21, 2003.

  1. Zhao

    Zhao Guest

    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
     
    Zhao, Sep 21, 2003
    #1
    1. Advertising

  2. Zhao

    Vladimir Anisimov

    Joined:
    Mar 9, 2007
    Messages:
    1
    This question is asked long ago and still not answered.

    This works for me:

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

    Wlodek
     
    Vladimir Anisimov, Mar 9, 2007
    #2
    1. Advertising

  3. Zhao

    miracle

    Joined:
    Dec 4, 2007
    Messages:
    1
    thank you, Wlodek!
     
    miracle, Dec 4, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gogo
    Replies:
    1
    Views:
    2,128
    Sudsy
    Sep 4, 2003
  2. Zhao

    logic:iterate in struts

    Zhao, Sep 11, 2003, in forum: Java
    Replies:
    2
    Views:
    8,433
    Sudsy
    Sep 11, 2003
  3. Indudhar
    Replies:
    1
    Views:
    2,713
    isitmeorthey
    Aug 27, 2005
  4. runescience
    Replies:
    0
    Views:
    1,479
    runescience
    Feb 9, 2006
  5. John
    Replies:
    4
    Views:
    944
    RedGrittyBrick
    Apr 1, 2008
Loading...

Share This Page