Skip to content

Commit 6ac61de

Browse files
committed
finnished lightSwitch
1 parent dbe235b commit 6ac61de

File tree

3 files changed

+47
-7
lines changed

3 files changed

+47
-7
lines changed

DriveThruOrder

Whitespace-only changes.

DriveThruOrder.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<html>
2+
<head>
3+
<title>Drive Through</title>
4+
<style>
5+
6+
</style>
7+
<script>
8+
var options = ["Hamburger", "Cheeseburger", "Shake", "Drink", "Fries"];
9+
var prices = [3.50, 3.75, 2.50, 1.00, 1.50];
10+
11+
function setOptions() {
12+
var optionsBox = document.getElementById("options");
13+
var txtArea = document.createElement("textarea");
14+
15+
for (var i = 0; i < options.length; i++) {
16+
txtArea.value = options[i];
17+
}
18+
19+
optionsBox.appendChild(txtArea);
20+
}
21+
</script>
22+
</head>
23+
<body onload="setOptions()">
24+
<div id=options>
25+
26+
</div>
27+
<div id=order>
28+
29+
</div>
30+
<div id=receipt>
31+
32+
</div>
33+
</body>
34+
</html>

LightSwitch.html

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,24 @@
44
<meta charset="UTF-8">
55
<title>Light Switch</title>
66
<style>
7-
7+
#bulb {
8+
width: 67;
9+
height: 103;
10+
}
11+
.sOn {
12+
transform: rotate(180deg);
13+
}
814
</style>
915
<script>
10-
const on = "on.jpg", off = "off.jpg";
16+
const on = "file:///D:/Programming/Repositories/HTML-JS-Examples/on.jpg", off = "file:///D:/Programming/Repositories/HTML-JS-Examples/off.jpg";
1117

1218
function switchLight() {
13-
var img = document.getElementsByTagName("img");
14-
if (img[0].src == "off.jpg") {
15-
img[0].src = "on.jpg";
19+
var img = document.getElementsByTagName("img");
20+
if (img[0].currentSrc == off) {
21+
img[0].src = on;
1622
img[1].setAttribute("class", "sOn");
1723
} else {
18-
img[0].src = "off.jpg";
24+
img[0].src = off;
1925
img[1].setAttribute("class", "sOff");
2026
}
2127
}
@@ -24,7 +30,7 @@
2430
</head>
2531
<body>
2632
<div id="bulb">
27-
<img src="off.jpg"/>
33+
<img src="D:\Programming\Repositories\HTML-JS-Examples\off.jpg"/>
2834
</div>
2935
<div id="switch">
3036
<img src="switch.png" onclick="switchLight()"/>

0 commit comments

Comments
 (0)