Prev Demo
JavaScript
>
Add And Assign
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>Add and Assign</h1> <script> function Addassignvalue() { var a = document.getElementById("txtA").value; var result = 5; result += parseInt(a); // result = result + parseInt(a); alert(result); } </script> Enter digit : <input type="text" id="txtA" name="txtA" /> <input type="button" name="btnAddassignvalue" value="Add & Assign value" onclick="Addassignvalue()" /> </body> </html>
Note: We DO NOT save your trial code in our database.
Output