Why the following code does not run, It supposes to run according to http://jsfiddle.net/NF7x9/. On the full HTML page, it does not work. My second question is how to pass the Total Calculated Value to the next page where another asp script requires the total value.
<html>
<head>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
var subt_value = parseFloat($('#subt0').text());
var start_price = parseFloat($('#subt0').attr('data-original'));
$("#ser1, #ser2").click(function(){
var sub_total = 0
var extra_fee = parseFloat($(this).attr('data-price')/1.12).toFixed(2);
$(this).each(function(){
if($(this).is(":checked")){
var sub_total = subt_value + parseFloat(extra_fee);
$('#subt0').text(parseFloat(sub_total).toFixed(2));
}else{
$('#subt0').text(parseFloat(start_price).toFixed(2));
}
});
});
</script>
</head>
<body>
<form name="tst">
<label id="subt0" data-original="8.90">8.90</label>
<input name="service1" type="checkbox" id="ser1" data-price="1" value="1" title="Service 1" />
<input name="service2" type="checkbox" id="ser2" data-price="5" value="1" title="Service 2" />
</form>
</body>
</html>
` tag - ie at the end of the body. Add `console.log($("#ser1, #ser2").length)` in your code - it will be `0` in the `
`/at the start of `
` and `2` if you move your code to the end (inside ``)
– freedomn-m Apr 23 '21 at 09:05