Hi All
I am a very beginner when it comes to jquery etc and am chuffed that I have managed to get me form working so far.
I have a form that when someone enters a value it automatically adds everything up… here is my code that is working fine:
$(function(){
$('#groceries, #petrol').keyup(function(){
var groceries = parseFloat($('#groceries').val()) || 0;
var petrol = parseFloat($('#petrol').val()) || 0;
$('#sum').val((groceries*0.05) + (petrol*0.05));
});
});
I need to show the result (sum) to 2 decimal places.
Can someone please let me know how I can do that.
Also the result is showing in a number input:
<input type="number" name="sum" id="sum" class="border-0" style="padding:0em; width:120px; font-weight:bolder;" placeholder="0" readonly>
I would LOVE to be able to echo the result in a <span>
or something… I tried <span id="sum"></span>
but that did not work.
Is this possible and how?
Thanks for any help.
mrmbares