JSFiddle - React, Tailwind, and code Playground
by revathskumar
HTML
<table>
<tr>
<td>
<input checked="checked" type="checkbox" class="processPaymentProducts" name="processPaymentProducts[]" value="1" />
<input type="hidden" id="prodPrice1" name="prodPrice[1]" value="1" />
</td>
<td>
<input checked="checked" type="checkbox" class="processPaymentProducts" name="processPaymentProducts[]" value="2" />
<input type="hidden" id="prodPrice2" name="prodPrice[2]" value="2" />
</td>
</tr>
</table>
<input type="text" id="processPaymentAmount"/>
JavaScript
jQuery(function($) {
$(".processPaymentProducts").change(function(){
var amount = 0;
jQuery.each($(".processPaymentProducts:checked"), function() {
amount += parseInt($(this).next('input').val());
console.log($(this).next('input').val());
});
if(amount>100) {
amount = amount/100;
}
$('#processPaymentAmount').val(amount);
});
});