-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadd.html
111 lines (93 loc) · 3.34 KB
/
add.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
<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">
<link rel="stylesheet" href="styles/style.css">
<title>Add Data</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css"
integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"
integrity="sha512-AA1Bzp5Q0K1KanKKmvN/4d3IRKVlv9PYgwFPvm32nPO6QS8yH1HO7LbgB1pgiOxPtfeg5zEn2ba64MUcqJx6CA=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<style>
* {
font-family: Roboto, Arial, Helvetica, sans-serif;
}
nav {
height: 70px;
background-color: rgba(0, 47, 52, 0.03);
box-shadow: rgba(0, 0, 0, 0.15) 1.95px 1.95px 2.6px;
display: flex;
align-items: center;
}
#back-arrow {
margin-left: 30px;
scale: 1.4;
}
button {
font-size: 20px;
width: 10%;
margin: auto;
height: 48px;
border-radius: 4px;
background-color: #ededed;
margin-top: -1px;
color: #5f686e;
}
#post-data {
display: grid;
height: 100vh;
width: 100%;
/* background: rgb(162, 1, 255) */
}
input {
width: 32%;
height: 51px;
padding: 12px;
margin: auto;
border-radius: 4px;
}
</style>
</head>
<body>
<nav>
<a href="sell.html" id="back-arrow"><i class="fa-solid fa-arrow-left-long"></i></a>
</nav>
<div class="heading">
<h1>POST YOUR AD</h1>
</div>
<div id="post-data">
<input type="text" id="img1" placeholder="Enter Image URL">
<input type="text" id="name" placeholder="Enter Title">
<input type="text" id="address" placeholder="Enter Your Address">
<input type="text" id="State" placeholder="Enter State">
<input type="text" id="price" placeholder="Enter Price">
<button id="post" onclick="addata()">Post now</button>
</div>
</body>
<script>
let data_array = JSON.parse(localStorage.getItem("products")) || [];
let addata = () => {
function obj(i, n, a, s, p) {
this.image1 = i;
this.name = n;
this.address = a;
this.State = s;
this.price = p;
}
let img1 = document.getElementById("img1").value;
let name = document.getElementById("name").value;
let address = document.getElementById("address").value;
let State = document.getElementById("State").value;
let price = document.getElementById("price").value;
let post_data = new obj(img1, name, address, State, price);
data_array.push(post_data);
swal("Ad Posted Successfully", "", "success").then(function () {
localStorage.setItem('products', JSON.stringify(data_array));
location.href = "index.html";
});
}
</script>
</html>