i have two input fields.
I have to divide one fields for the other
This is my javascript code
$("#circonferenza_vita").on("change",function(){
var vita = $('#circonferenza_vita').val();
var fianchi = $('#circonferenza_fianchi').val();
alert(vita + " " + fianchi);
var whr = (vita / fianchi);
$('#whr').val(whr);
});
});
But when i insert the value in the input fields i have a wrong result.
For example if i insert vita 90 and fianchi 75 the result should be 0.8333 but i receive the result 1.2
Note that the alert return the correct values for vita and fianchi but the result is wrong.
Someone can help to understand and fix this issue? It is driving me crazy 🙂
3
Answers
Sorry, I inverted the variables in division. Thanks to all.
Man, just swap your numbers, 90/75 = 1.2, that’s right. Have a good sleep then!
Your Code is :
You said
if i insert vita 90 and fianchi 75 the result should be 0.8333 but i receive the result 1.2
. But it Should be1.2
(90/75
). Please Check your variables & Given Values.