How to Read and Write Data from HTML in JavaScript
Free Web development courses with real-time projects Start Now!!
Program 1
<html><head><title>Test Java Script variables</title> <script lang="javascript"> function addition() { var a,b,c a=document.getElementById("txtFirst").value; b=document.getElementById("txtSecond").value; a=parseInt(a) b=parseInt(b) c=a+b document.getElementById("txtThird").value=c //alert(c) //document.write(a); //document.write("<br>") //document.write(b); } </script> </head> <body> <center> <form> <table border="1"> <tr> <th>Enter First Number</th> <td><input type=text name="txt1" id="txtFirst"></td> </tr> <tr> <th>Enter Second Number</th> <td><input type=text name="txt2" id="txtSecond"></td> </tr> <tr> <th>Result</th> <td><input type=text name="txt3" id="txtThird"></td> </tr> <tr> <td></td> <td><input type=button value="Addition" onclick="addition()"></td> </tr> </table> </form> </center> </body> </html>
Your opinion matters
Please write your valuable feedback about DataFlair on Google