I would see if id exists, i.e.
while(cnt <= numitems) { var curItem = document.getElementById('item_subtotal[' + cnt + ']'); if(curItem!=null){ totalAmt = parseInt(totalAmt) + parseInt(curItem.value); } cnt++; }
Also, I would use the Firebug extension for Firefox to see what could go wrong:
while(cnt <= numitems) { var curItem = document.getElementById('item_subtotal[' + cnt + ']'); if(curItem!=null){ totalAmt = parseInt(totalAmt) + parseInt(curItem.value); }else{ console.log('Couldn\'t find element item_subtotal[' + cnt + ']'); } cnt++; }
source share