-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathArrayOfObjects.html
59 lines (56 loc) · 2.11 KB
/
ArrayOfObjects.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
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.css">
<script>
var products = [
{Name: "Samsung TV", Price: 35000.66, Photo:"../Images/tv.jpg"},
{Name: "Nike Casuals", Price: 6000.22, Photo:"../Images/shoe.jpg"},
{Name: "LG Mobile", Price: 12000.55, Photo:"../Images/mobile.jpg"},
{Name: "Lee Cooper Boot", Price: 3000.45, Photo:"../Images/shoe1.jpg"},
];
function GetProduct(index) {
document.getElementById("lblName").innerHTML =
products[index].Name;
document.getElementById("imgPic").src=
products[index].Photo;
document.getElementById("lblDetails").innerHTML =
"₹" + products[index].Price;
}
function bodyload() {
GetProduct(0);
}
var i = 0;
function NextClick() {
i++;
GetProduct(i);
}
function PreviousClick() {
i--;
GetProduct(i);
}
</script>
</head>
<body onload="bodyload()" class="text-center">
<div class="container">
<h2>Amazon Shopping Cart</h2>
<div class="text-center">
<div class="card">
<div style="color:white" class="card-header bg-primary">
<h2 id="lblName" class="card-title">
</h2>
</div>
<div class="card-body">
<button class="btn btn-primary btn-lg" onclick="PreviousClick()"> < </button>
<img src="" id="imgPic" class="img-thumbnail" height="300" width="300">
<button class="btn btn-primary btn-lg" onclick="NextClick()"> > </button>
</div>
<div style="color:white" class="card-footer bg-secondary">
<h3 id="lblDetails">
</h3>
</div>
</div>
</div>
</div>
</body>
</html>