Skip to content

Commit 852dfcc

Browse files
committed
Finished exercise 1 of chapter 11
1 parent 24ad287 commit 852dfcc

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

ch11exercise1.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Chapter 11</title>
5+
</head>
6+
<body>
7+
<h1>Centigrade to Fahrenheit Converter</h1>
8+
<form id="form1" name="form1">
9+
<input type="number" name="centigrade" id="centigrade" />
10+
<br />
11+
<output id="result" name="result" for="centigrade"></output>
12+
</form>
13+
<script>
14+
//exercise 1
15+
function newValue() {
16+
var degCent = document.form1.centigrade.value;
17+
var degFahren = (9.0 / 5) * degCent + 32;
18+
19+
document.form1.result.value = degFahren;
20+
}
21+
document.form1.addEventListener("input", newValue);
22+
</script>
23+
</body>
24+
</html>

0 commit comments

Comments
 (0)