html - Simple Javascript Calculator -



html - Simple Javascript Calculator -

i'm trying larn javascript , sense have decent grasp on fundamentals having problems making things want .. example.. trying create simple form in html calculates sum of 2 numbers.. here html , javascript:

<head> <script type="text/javascript"> function adder(a,b) { var = document.getelementbyid('firstnum').value; var b = document.getelementbyid('secondnum').value; var numbers = new array(a,b); var sum = 0; (i=0; < numbers.length; i++) { sum += parseint(numbers[i]); } //this part need help document.getelementbyid('answer').write("first number: " + + " plus sec number: " + b + " " + sum).value; //this part need help </script> </head> <body> <form id="additionform"> + b = c : <input type="text" id="firstnum" placeholder="a"> + <input type="text" id="secondnum" placeholder="b"> <input type="button" id="addbtn" value="add" onclick="adder();"> = <input type="text" id="answer" placeholder="c"> </form> </body>

my problem don't know how javascript overwrite value attribute form input id=answer .. or if i'm supposed using jquery instead .. in advance.

function adder() { var = parseint( document.getelementbyid('firstnum').value, 10); var b = parseint( document.getelementbyid('secondnum').value, 10); var sum = + b; //this part need help document.getelementbyid('answer').value = "first number: " + + " plus sec number: " + b + " " + sum).value; //this part need help }

javascript html

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -