-
Notifications
You must be signed in to change notification settings - Fork 0
/
book.html
96 lines (75 loc) · 2.66 KB
/
book.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
<!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>Wander Wisely with the Travelocity app</title>
<link rel="stylesheet" href="book.css">
<link rel="stylesheet" href="nav.css">
</head>
<body>
<nav>
<label class="logo"> <img src="https://www.logolynx.com/images/logolynx/9c/9c0d38dfefbb1a00369d482de4e96c4a.jpeg" alt="Booking"/> </label>
<ul>
<li><a class="active" href="index.html">Espanol</a></li>
<li><a href="place.html">Resort</a></li>
<li><a href="#">Supports</a></li>
<li><a href="book.html">Bookings</a></li>
<li><a href="login.html">Login</a></li>
<li><a href="signup.html">Sign up</a></li>
</ul>
</nav>
<div id="total">
<h2>Total Amount :- <span id="total-value">0</span></h2>
<button>Paynow</button>
</div>
<div id="container"></div>
</body>
<script>
let booking = JSON.parse(localStorage.getItem("book")) || [];
let totalprice = document.getElementById("total-value");
function display(booking){
document.getElementById("container").innerHTML="";
let total = 0;
booking.forEach(function(el,index){
total += Number(el.price);
let div = document.createElement("div");
let img = document.createElement("img");
img.src = el.img;
let h2 = document.createElement("h3");
h2.innerText = el.name;
let h3 = document.createElement("h4");
h3.innerText = el.Place;
let p = document.createElement("h5");
p.innerText = el.rate;
let hr = document.createElement("hr");
let h4 = document.createElement("h2");
h4.innerText = el.offer;
let h1 = document.createElement("h1");
h1.innerText = el.price;
let p1 = document.createElement("p");
p1.innerText = el.day;
let newbtn = document.createElement("button");
newbtn.innerText = "Remove";
newbtn.addEventListener("click",function(){
removetobook(index);
});
div.append(img,h2,h3,p,hr,h4,h1,p1,newbtn);
document.querySelector("#container").append(div);
totalprice.innerText=total;
});
}
display (booking)
function removetobook(index){
booking.splice(index,1);
localStorage.setItem("book",JSON.stringify(booking));
display(booking)
}
let btn = document.querySelector("button");
let button = btn.addEventListener("click",function(){
alert("Booking Successful")
return booking.length="";
});
</script>
</html>