I am trying to perform simple calculation using Jquery on input fields but cannot make it work.
<label for="a"><input type="number" id="a" value="1" size="2" maxlength="1"></label>
<label for="b"><input type="number" id="b" value="1" size="2" maxlength="1"></label>
<div class="button">
<a name="qtybutton" onClick="calculation()">update</a>
</div>
<script>
function calculation() {
variable = new XMLHttpRequest();
var total = 0;
var sqty = $('#a').val();
var itemprice = $('#b').val();
var total = sqty * itemprice;
$('#total').val(total);
alert("OK");
}
</script>
I get alert "OK" so at least I know that jquery function is working, but no calculation is performed. I would be thankful for any suggestions.
<input id='total' type='text' />element? You need an input to set the value of.