javascript - Remove First Character and Add Values -


this question has answer here:

i'm using autonumeric jquery plugin place dollar sign , decimal a couple of text fields. want add these 2 values, i'm getting nan error because of dollar sign placed in front of number.

how remove dollar sign (first character), add values , place total value field?

sample html

<input type="text" id="value_one" /><br /> <input type="text" id="value_two" /><br /> <input type="text" id="total_value" /><br /> 

sample jquery

$("body").hover(function() {     var = +$('#value_one').val();     var b = +$('#value_two').val();     var total = a+b;     $('#total_value').val(total); }); 

fiddle

jquery

$("#totalme").click(function () {     var = $('#value_one').val();     var b = $('#value_two').val();     var flta = number(a.replace(/[^0-9\.]+/g, ""));     var fltb = number(b.replace(/[^0-9\.]+/g, ""));     var total = flta + fltb;     $('#total_value').val(total); }); 

html

<input type="text" id="value_one" /> <br /> <input type="text" id="value_two" /> <br /> <input type="text" id="total_value" /> <br /> <button id="totalme">total</button> 

jsfiddle


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -