-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDriveThruOrder-Done2.html
115 lines (97 loc) · 3.87 KB
/
DriveThruOrder-Done2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<html>
<head>
<title>Drive Through</title>
<style>
div {
margin: 10px;
}
textarea {
height: 100px;
background-color: lightgrey;
}
span {
min-width: 48px;
margin: 2px;
}
#receipt {
all: initial;
border: black 3px solid;
width: 200px;
display: inline-block;
overflow-x: auto;
white-space: nowrap;
min-height: 10px;
}
#orderPanel {
position: fixed; top: 20%; left: 50%;
}
.panel {
all: inherit;
display: inline-block;
border: violet 7px dotted;
font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
}
</style>
<script src="jquery.js"></script>
<script>
var options = ["Hamburger", "Cheeseburger", "Tenderloin", "Shake", "Drink", "Fries"];
var prices = [3.50, 3.75, 5.00, 2.50, 1.00, 1.50];
var sum = 0;
function setOptions() {
var optionsBox = document.getElementById("options");
var txtArea = document.createElement("textarea");
for (var i = 0; i < options.length; i++) {
if (i == options.length - 1) {
var tn = document.createTextNode(options[i] + " $" + prices[i].toString());
} else {
var tn = document.createTextNode(options[i] + " $" + prices[i].toString() + "\n");
}
txtArea.appendChild(tn);
}
txtArea.setAttribute("readonly", true);
optionsBox.appendChild(txtArea);
}
function printReceipt() {
var order = document.getElementById("order");
for (var i = 0; i < options.length; i++) {
if (order.value == options[i]) {
var span1 = document.createElement("span");
var span = document.createElement("span");
var item = document.createTextNode(order.value);
var price = document.createTextNode("$" + prices[i].toString());
var a = prices[i];
sum += a;
span1.appendChild(item);
span.appendChild(price);
document.getElementById("total").removeChild(document.getElementById("total").firstChild);
document.getElementById("receipt").appendChild(span1);
document.getElementById("receipt").appendChild(span);
document.getElementById("receipt").appendChild(document.createElement("br"));
document.getElementById("total").appendChild(document.createTextNode("$" + sum.toString()));
break;
}
}
order.value = "";
}
$(document.body).ready("setOptions()");
</script>
</head>
<body >
<div id=orderPanel class=panel>
<p>Menu:</p>
<div id=options>
</div>
<p>Order Here:</p>
<div id=in>
<input id=order type=text placeholder="Tenderloin"></input>
<button type="submit" id=submit onclick="printReceipt()" value="Submit">Submit</button>
</div>
<p>Receipt:</p>
<div id=receipt>
</div>
<p>Total: </p>
<span id=total style=all:unset;>
</span>
</div>
</body>
</html>