html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form>
Number 1: <input type="text" id="num1"><br>
Number 2: <input type="text" id="num2"><br>
Sum: <input type="text" id="sum"><br>
<input type="button" value="Sum" onclick="calcSum()">
</form>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
body {
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
function calcSum() {
let num1 = document.getElementById("num1").value;
let num2 = document.getElementById("num2").value;
let sum = Number(num1) + Number(num2);
document.getElementById("sum").value = sum;
}
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run