priyaravisekar
10-19-2009, 08:59 PM
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
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
<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>
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
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
<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>