JS a+b=c

<script>
function add(){
var a,b,c;
a=Number(document.getElementById("first").value);
b=Number(document.getElementById("second").value);
c= a + b;
document.getElementById("answer").value= c;
}
</script>

Enter the First number : <input id="first" /><br />
Enter the Second number: <input id="second" /><br />
<button onclick="add()">Add</button>
<input id="answer" />


Enter the First number :
Enter the Second number:

No comments:

Post a Comment