I'm new to JavaScript, I'm building a calculator
I input values Is stored in the variable so that I can finally manipulate the results to calculate based on input. For now, I want to add all the values.
However, instead of adding, they connect each other. I use parseInt to prevent javascript from viewing as strings, and type it shows that these numbers are there.
This is my javascript:
$ (document) .ready (Val (); var thePrice = $ ( "# thePrice"). Val (); var val (); var theTrade = $ ( "# theTrade"). val (); var theResult = parseInt (theTerm + reserve + thePrice + theTax + theown + theTrade, 10); $ ( "# count") click (function ( ) {Alert (theResult); Alert (theResult);});});
and HTML:
& lt; Div id = "calculator" & gt; & Lt; Span id = "calculator header" & gt; Monthly payment calculator & lt; / Span & gt; & Lt; Table style = "margin: 0 auto;" & Gt; & Lt; TR & gt; & Lt; Td style = "width: 40px;" & Gt; Period & lt; Input id = "The term" size = "5" value = "7" name = "word" style = "width: 35px" /> & Lt; / TD & gt; & Lt; Td style = "width: 40px;" & Gt; Rate (%) & lt; Input ID = "The right" size = "5" value = "7" name = "APR" style = "width: 35px" /> & Lt; / TD & gt; & Lt; Td style = "width: 55px;" & Gt; Price ($) & lt; Input id = "The value" size = "6" maximum length = "7" name = "value" style = "width: 50px" value = "7" /> & Lt; / TD & gt; & Lt; Td style = "width: 40px;" & Gt; Tax (%) & lt; Input id = "theTax" size = "4" maximum length = "7" name = "tax" style = "width: 35px" value = "7" /> & Lt; / TD & gt; & Lt; Td style = "width: 40px;" & Gt; Down ($) & lt; Input id = "theown" size = "5" maximum length = "7" name = "down PMT" style = "width: 35px" value = "7" /> & Lt; / TD & gt; & Lt; Td style = "width: 40px;" & Gt; Business ($) & lt; Input id = "theTrade" size = "5" maximum length = "7" name = "business" style = "width: 35px" value = "7" /> & Lt; / TD & gt; & Lt; Td style = "width: 78px;" & Gt; Astanthi PMT & lt; Input id = "theResult" size = "7" maximum length = "7" name = "results" style = "width: 75px" value = "0" /> & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; Button type = "button" id = "calculation" & gt; Add box! & Lt; / Button & gt; & Lt; / Div & gt;
Change the line and follow parseInt for each obj
< Pre> var theResult = parseInt (theTerm) + parseInt (thereate) + parseint (the pris) + parseint (ttx) + parseint (down) + parseint (the trade);
Comments
Post a Comment