-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathadmin-Page.html
More file actions
81 lines (59 loc) · 1.81 KB
/
Copy pathadmin-Page.html
File metadata and controls
81 lines (59 loc) · 1.81 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Product Info</title>
<style>
body {
font-family: sans-serif;
background-color: antiquewhite;
}
form {
width: 10%;
}
input {
margin-top: 8%;
padding: 5%;
}
</style>
</head>
<body>
<a href="clothing.html"> <button>Product Details</button></a>
<h2>Create New Product</h2>
<form onsubmit="getProdDetail(event)" id="myForm" >
<input type="img" id="image" placeholder=" Image link" />
<input type="text" id="avability" placeholder="Avability" />
<input type="text" id="tag" placeholder="Product Tag" />
<input type="text" id="name" placeholder="Product name" />
<input type="text" id="coloraval" placeholder="Color Count" />
<input type="text" id="price" placeholder="Product Price" />
<input type="submit" value="Submit">
</form>
</body>
<script>
function getProdDetail(e) {
e.preventDefault();
let myForm = document.getElementById('myForm');
let image = myForm.image.value;
let avability = myForm.avability.value;
let tag = myForm.tag.value;
let name = myForm.name.value;
let color = myForm.coloraval.value;
let price = myForm.price.value;
if (localStorage.getItem('prodDetail') === null) {
localStorage.setItem('prodDetail', JSON.stringify([]))
}
let prod = {
image,
avability,
tag,
name,
color,
price,
};
console.log(prod);
let arr = JSON.parse(localStorage.getItem('prodDetail'));
arr.push(prod);
localStorage.setItem('prodDetail', JSON.stringify(arr));
}
</script>
</html>