Adding a '+' sign makes it a number (or NaN): $('#b19').val(+b18 + (+b16*12) + +b15);
You should add either + or parseInt in your variable declarations at the beginning of your script. On Jul 30, 4:40 pm, kalyan Chatterjee <kalyan11021...@gmail.com> wrote: > Hi so in this case how to write this? > > $('#b19').val(b18 + (b16*12) + b15); > > Please tell me I am got stuck with this :( > > On Jul 31, 12:23 am, James <james.gp....@gmail.com> wrote: > > > Make sure to typecast your data from Strings to Integers/Floats before > > you do calculations on them. Otherwise, 1+1 may equal 11. > > Use the parseInt() or parseFloat() functions. > > >http://www.w3schools.com/jsref/jsref_parseInt.asphttp://www.w3schools... > > > On Jul 30, 9:15 am, kalyan Chatterjee <kalyan11021...@gmail.com> > > wrote: > > > > I am just trying to write this > > > > $(function(){ > > > $('#submit').click(function(){ > > > var b10 = $("input[name='avgtsize']").val(); > > > var b11 = $("input[name='avgisold']").val(); > > > var b12 = $("input[name='tfee']").val(); > > > var b13 = $("input[name='tpm']").val(); > > > var b15 = $("input[name='tsfee']").val(); > > > var b16 = $("input[name='mfree']").val(); > > > var b24 = $("input[name='raiseavg']").val(); > > > var b27 = $("input[name='targetC']").val(); > > > var b33 = $("input[name='avgmonth']").val(); > > > var b35 = $("input[name='incmonth']").val(); > > > > $('#userform').fadeOut('fast'); > > > $('#result').fadeIn('slow'); > > > $('#b10').val("$" + b10); > > > $('#b11').val(b11 + "%"); > > > $('#b12').val("$" + b12); > > > $('#b13').val("$" + b13); > > > $('#b15').val("$" + b15); > > > $('#b16').val("$" + b16); > > > > $('#b17').val("$" + b12); > > > $('#b18').val("$" + (b12*b13)*12); > > > var b18 =((b12*b13)*12); > > > var b15 = $("input[name='tsfee']").val(); > > > $('#b19').val(b18 + (b16*12) + b15); > > > }); > > > > }); > > > > On Jul 31, 12:07 am, "Cesar Sanz" <the.email.tr...@gmail.com> wrote: > > > > > What?? > > > > > Math science is exact... > > > > > Can you provide your script? > > > > > ----- Original Message ----- > > > > From: "kalyan Chatterjee" <kalyan11021...@gmail.com> > > > > To: "jQuery (English)" <jquery-en@googlegroups.com> > > > > Sent: Thursday, July 30, 2009 12:32 PM > > > > Subject: [jQuery] Simple calculation > > > > > > Hi Everyone, > > > > > > I am just trying to do a simple calculation - like 1440 + ( 99 * 12) > > > > > + 795 the result should be 3423. But I am getting different answer. > > > > > Please someone help me how to do it. > > > > > > Thanks > > > > > Kaly