Results 1 to 1 of 1

Thread: loop through elements within nested:iterate tag using javascript

  1. #1
    Join Date
    Oct 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default loop through elements within nested:iterate tag using javascript

    Hello,

    I would like to loop through the adjustedLineItems list and set the checkbox values to true on click of a select all button.
    I am getting the error document.all['adjustedLineItems[i].selected'] is null or not an object

    however it works if I manually substitute values for i within the function

    Code:
    document.all['adjustedLineItems[0].selected'].checked=true;
    document.all['adjustedLineItems[1].selected'].checked=true;
    document.all['adjustedLineItems[2].selected'].checked=true;
    Could someone please help me do this via a for loop?
    Thanks

    Code:
    <nested:iterate name="invoiceForm" property="adjustedLineItems" id="adjli" type="com.bt.lex.common.lineItem.beans.LineItemDetailBean" indexId="idxadjli">
    <tr>
    <td class="dataLeft"><nested:checkbox property="selected"/></td>
    <td class="dataLeft"><nested:write property="liNumber"/></td>
    </tr>
    </nested:iterate>
    
    <script type="text/javascript">
    
    function onclick_all(ctl) {
    var checkFlag = "false";
    var count = document.all.numOfAdjustedLIs.value;
    var i = 0;
    //alert(count);
    if(ctl.checked)
    {
    if(checkFlag=="false")
    {
    for (i = 0; i <count; i++)
    {
    document.all['adjustedLineItems[i].selected'].checked=true;
    }
    checkFlag = "true";
    }
    }
    }
    </script>
    Last edited by jscheuer1; 10-20-2009 at 01:36 AM. Reason: format code

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •