-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMcDonald.html
168 lines (142 loc) · 5.57 KB
/
McDonald.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>McDonald</title>
</head>
<style>
#main_div {
margin: auto;
width: 300px;
height: 200px
}
#myform {
width: 80%;
height: 100px;
margin: auto;
margin-top: 30px;
display: flex;
justify-content: space-around;
padding: 40px;
}
input {
width: 20px;
height: 20px;
cursor: pointer;
}
label {
font-size: 25px;
font-weight: bold;
font-family: 'Times New Roman', Times, serif;
color: white;
cursor: pointer;
}
#btn {
width: 130px;
height: 40px;
padding: 10px 20px;
border-radius: 10px;
color: white;
background-color: orange;
cursor: pointer;
}
body {
background-image: url("https://ffwallpaper.com/thumb/mcdonalds/mcdonalds-8.jpg");
background-repeat: no-repeat;
background-size: cover;
width: 100%;
height: 100vh;
background-position: center;
margin-top: 2px;
}
</style>
<body>
<form id="myform">
<div>
<input type="checkbox" id="item1" name="" value="Chicken">
<label>Chicken</label><br>
</div>
<div>
<input type="checkbox" id="item2" name="" value="Burger">
<label>Burger</label><br>
</div>
<div>
<input type="checkbox" id="item3" name="" value="Pizza">
<label>Pizza</label>
</div>
<button onclick="orderingitem(event)" id="btn">Order Food</button>
</form>
<div id="main_div"></div>
</body>
</html>
<script>
function orderingitem(event) {
event.preventDefault()
let item1 = document.getElementById("item1")
let item2 = document.getElementById("item2")
let item3 = document.getElementById("item3")
let maindiv = document.getElementById("main_div")
let shop = "open"
if (item1.checked == true || item2.checked == true || item3.checked == true) {
let orderpromise = new Promise(function (resolve, reject) {
setTimeout(function () {
if (shop === "open") {
if (item1.checked == true) {
maindiv.innerHTML = null
resolve(alert("order success"))
let div = document.createElement("div")
let img = document.createElement("img")
img.setAttribute("src", "https://www.kitchensanctuary.com/wp-content/uploads/2019/08/Korean-Fried-Chicken-square-FS-New-7377.jpg", "https://106fyz3cd4vi2lc2uq1tlyl4-wpengine.netdna-ssl.com/wp-content/uploads/2020/09/Moist-Chicken-Burgers.jpg")
img.style = "width:250px;height:250px"
div.append(img)
let id = document.createElement("h1")
id.textContent = Math.round(Math.random() * 10 + 1)
id.style = "color:white;font-size:40px;margin-left:50px"
div.append(id, img)
maindiv.append(div)
}
if (item3.checked == true) {
maindiv.innerHTML = null
resolve(alert("order success"))
let div = document.createElement("div")
let img = document.createElement("img")
img.setAttribute("src", "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQTHeE4Amu7RBqidPpw_Vbs-BcYw-as0zWQIGlkNHn4QCCPgSt4BtEZeD3LEbWx6FVep_0&usqp=CAU")
img.style = "width:250px;height:250px"
div.append(img)
let id = document.createElement("h1")
id.textContent = Math.round(Math.random() * 10 + 1)
id.style = "color:white;font-size:40px;margin-left:50px"
div.append(id, img)
maindiv.append(div)
}
if (item2.checked == true) {
maindiv.innerHTML = null
resolve(alert("order success"))
let div = document.createElement("div")
let img = document.createElement("img")
img.setAttribute("src", "https://106fyz3cd4vi2lc2uq1tlyl4-wpengine.netdna-ssl.com/wp-content/uploads/2020/09/Moist-Chicken-Burgers.jpg")
img.style = "width:250px;height:250px"
div.append(img)
let id = document.createElement("h1")
id.textContent = Math.round(Math.random() * 10 + 1)
id.style = "color:white;font-size:40px;margin-left:50px"
div.append(id, img)
maindiv.append(div)
}
}
}, 2000)
})
orderpromise.then(function (res) {
console.log(res)
})
.catch(function (err) {
console.log(err)
})
}
else {
alert("Please Order as your choice")
}
}
</script>