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:

subtracted few times, added text

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

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -