-
Notifications
You must be signed in to change notification settings - Fork 0
/
buy.html
68 lines (60 loc) · 2.05 KB
/
buy.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Buy Item</title>
<style>
.item {
display: flex;
flex-direction: column;
align-items: center;
margin: 20px;
}
.item img {
max-width: 200px;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="item" id="itemDetails">
<!-- Item details will be populated here -->
</div>
<button onclick="purchase()">Purchase</button>
<script>
function getQueryParams() {
const params = new URLSearchParams(window.location.search);
return {
img: params.get('img'),
title: params.get('title'),
label: params.get('label'),
option: params.get('option')
};
}
function displayItemDetails() {
const itemDetails = getQueryParams();
// Create and set image
var img = document.createElement('img');
img.setAttribute('src', itemDetails.img);
// Create and set title
var title = document.createElement('div');
title.innerText = itemDetails.title;
// Create and set label with option
var label = document.createElement('div');
label.innerText = `${itemDetails.label}: ${itemDetails.option}`;
// Append elements to the item details container
var itemContainer = document.getElementById('itemDetails');
itemContainer.append(img);
itemContainer.append(title);
itemContainer.append(label);
}
function purchase() {
alert('Item purchased successfully!');
// Add actual purchase logic here
}
// Display item details on page load
window.onload = displayItemDetails;
</script>
</body>
</html>