Queries and SolutionsCategory: Questionshow to get sum of two numbers with using only enter button
vandana asked 11 years ago

In using forms in javascript we have a coding like this:
<html>
<Title>using forms in javascript</title>
<script>
var a,b
function add()
{
a=parseInt(document.f1.t1.value)
b=parseInt(document.f1.t2.value)
document.f1.t3.value=a+b
}
</script>
<body>
<form name=”f1″>
Number one:<input type=”text” name=”t1″ />
<br><br>
Number two:<input type=”text” name=”t2″ />
<br><br>
Result:<input type=”text” name=”t3″ />
<br><br>
<input type=”button” value=”Add two numbers” onClick=”add
()”><input type=”reset”>
</form>
</body>
</html>
 
But in this we have to click on “add two numbers” button but if we have to find the sum of two numbers without using button, if we enter number by user and press enter then result will automatically show in result column…. is it possible to do in javascript?

Your Answer

0 + 2 =