JSFiddle - React, Tailwind, and code Playground
HTML
<form action="#" method="post">
<input name="type" value="" type="checkbox" /><br />
<input name="service_price" value="" type="text" /><br />
<input name="modem_price" value="" type="text" /><br />
<input id="total_price" name="" value="" type="text" />
</form>
JavaScript
function compute() {
if ( $('input[name=type]:checked').val() != undefined ) {
var a = parseInt($('input[name=service_price]').val());
var b = parseInt($('input[name=modem_price]').val());
var total = a+b;
$('#total_price').val(a+b);
}
}
jQuery('form').delegate('input[name=type], input[name=service_price], input[name=modem_price]','change', compute);