What I need is when the updateTotal function triggers (by checking or unchecking the checkbox), it loops the itemprice column and adds it to the totalPrice variable if it's corresponding checkbox located in tditem column is checked. Else, don't add the itemprice's value to totalPrice. Thanks in advance!
<table id="tblItem">
<body>
<tr>
<td class="hidden" id="tditemid"></td>
<td id="tditem">
<input type="checkbox" id="chckItemId" name="selectedItems" checked="checked" onclick="updateTotal(this)" />
<label id="lblitem"></label>
</td>
<td id="itemprice"></td>
<td class="hidden" id="tdstatus"></td>
</tr>
</body>
</table>
<input class="form-control input-sm" id="total" name="totalprice" readonly="true" type="text" value="">
Javascript
//Update total textbox when checkbox is checked/unchecked
window.updateTotal = function (element) {
var totalPrice = 0.00;
//Get clicked dropdown row and col id
var chckRow = element.parentNode.parentNode.rowIndex;
var chckCol = element.parentNode.cellIndex;
//What to do??
//Display total price
$('#totalprice').val(totalPrice);
}
Aucun commentaire:
Enregistrer un commentaire