JSFiddle - React, Tailwind, and code Playground
by EveGeen
HTML
<form>
<select id="percent">
<option value="10">10%</option>
<option value="20">20%</option>
</select>
<input type="text" name="b" value="0">
<label>Price</label>
<input type="text" name="c" value="">
</form>
JavaScript
function calc()
{
var tot1=parseInt($('#percent').val());
var tot2=parseInt($("input[name='b']").val());
var tot=tot2/100*tot1+tot2;
$('input[name="c"]').val(tot);
}
$('#percent').change(function() {
calc();
});
$('input[name="b"]').change(function() {
calc();
});