I have this field at my form for calculating Value Added Tax:
JavaScript
x
17
17
1
<form method="post" action="" id="form-product">
2
<div class="col-md-4">
3
<div class="form-check">
4
<input class="form-check-input" type="radio" id="vat" name="vat" value="on">
5
<label class="form-check-label">
6
Calculate VAT
7
</label>
8
</div>
9
<div class="form-check">
10
<input class="form-check-input" type="radio" id="vat" name="vat" value="off" checked>
11
<label class="form-check-label">
12
Do not calculate VAT
13
</label>
14
</div>
15
</div>
16
</form>
17
Now within jQuery, I want to check that if the radio button is set to the value on, do the calculation.
So how can I do that with jQuery.
I would really appreciate any idea or suggestion from you guys…
Thanks in advance.
Advertisement
Answer
I have added a listener to get the value from the radio button.
JavaScript
1
4
1
$('#form-product input').on('change', function() {
2
alert($('input[name=vat]:checked', '#form-product').val());
3
});
4
for more info in Jquery refer to this question