jquery javascript set values as float before adding -
my app has textbox on webpage value looked , added or subtracted value.
it seems subtract well, when adding, interprets value in textbox text, , adds on other float text well:
here's source code of thing changing:
$('#mymoney').val($('#mymoney').val() + $prevevent.close); //...or when subtracting:...// $('#mymoney').val($('#mymoney').val() - $prevevent.close);
how tell mymoney interpreted float instead of string?
this because .val()
reading value string , concatinating. can parse integer parseint()
:
$('#mymoney').val( parseint($('#mymoney').val()) + $prevevent.close);
for float values use parsefloat()
:
$('#mymoney').val( parsefloat($('#mymoney').val()) + $prevevent.close);
Comments
Post a Comment