I have added this field to my form in order to calculate value added tax (vat):
<div class="col-md-4">
<div class="form-check">
<input type="radio" id="vat_on" name="vat" value="on" checked>
<label class="form-check-label">
Calculate value added tax
</label>
</div>
<div class="form-check">
<input type="radio" id="vat_off" name="vat" value="off">
<label class="form-check-label">
Do not calculate value added tax
</label>
</div>
</div>
And I tried adding this as jQuery:
if($('[name=vat]:checked').val() === 'on'){
var value_added_tax = ((price_final*cnt) - ((price_final*cnt)*0.9)).toLocaleString();
}else{
var value_added_tax = (0).toLocaleString();
}
But when I test this and checked the Calculate value added tax
radio button, it returns: Nan !
However it should be returning a value instead of Nan.
I have also tried removing toLocaleString()
from both conditions, but didn't solve the problem.
So what is going wrong here ? How can I fix this issue ?
I would really appreciate any idea or suggestion from you guys...
Thanks in advance.
from jQuery does not calculate Value Added Tax on Form
No comments:
Post a Comment