forked from Rohit27698/carver_Clone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
address.html
236 lines (160 loc) · 7.48 KB
/
address.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<!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>Address Page</title>
<link rel="stylesheet" href="Address.css">
</head>
<body>
<div id="navbar_div"></div>
<div id="parent">
<div id="text_content">
<h1>Choose Address</h1>
<p id="Detail">Detailed address will help our delivery partner reach your doorstep quickly</p>
</div>
<div id="boxes">
<div id="Add_Address">
<img src="https://img.icons8.com/?size=1x&id=40097&format=png" alt="+">
<p >Add New Address</p>
</div>
<div id="display_Add">
<p style="color:solid rgb(10, 9, 9);">Your contact data </p>
</div>
<div id="display_bag">
<div id="bag">
<img src="https://adn-static1.nykaa.com/media/wysiwyg/Payments/DesktopRevamp_icons/Icon.svg"
alt="">
<h3>Bag</h3>
<span id="Items" style="margin-left: 100px; margin-top: 20px; font-weight: 600;"> Items :- </span>
</div>
<div id="price">
<img src="https://adn-static1.nykaa.com/media/wysiwyg/Payments/DesktopRevamp_icons/ic_payment_details-03.svg"
alt="">
<h3>Price</h3>
<span id="Grand_total" style="margin-left: 100px; margin-top: 20px; font-weight: 600;"> ₹ </span>
</div>
<div id="authentic">
<p>Buy authentic products. Pay securely. Easy returns and exchange.</p>
<img src="https://img.icons8.com/?size=1x&id=4gkX7WKBMH7z&format=png"
alt="" onclick="">
</div>
</div>
</div> <!-- //boxes -->
</div>
<div id="footer">
</div>
</body>
<script type="module" src="index.js"></script>
<script>
// import navbar from "../components/navbar.js";
// let navbarDiv = document.getElementById("navbar_div");
// navbarDiv.innerHTML = navbar();
// import footer from "../components/footer.js";
// let footerdiv=document.getElementById("footer")
// footerdiv.innerHTML=footer();
document.querySelector("#Add_Address").addEventListener("click" , Dis_form);
function Dis_form(){
var form = document.createElement("form");
var close_img = document.createElement("img");
close_img.setAttribute("id", "close_id")
close_img.setAttribute("src", "https://adn-static1.nykaa.com/media/wysiwyg/Payments/Clear.svg");
close_img.style.width = "30px";
close_img.setAttribute("onclick" , "closeForm()");
var head = document.createElement("h2");
head.textContent = "New Address";
var div = document.createElement("div");
div.append(close_img,head);
div.setAttribute("id", "close&head");
div.style.display = "flex";
var head2 = document.createElement("h2");
head2.textContent = "Address";
var in4 = document.createElement("input"); //address
in4.setAttribute("placeholder", "House No / Flat No");
in4.setAttribute("type", "text");
in4.setAttribute("id", "in4");
var in5 = document.createElement("input"); //pincode
in5.setAttribute("placeholder", "pincode");
in5.setAttribute("type", "number");
in5.setAttribute("id", "in5");
var in6 = document.createElement("input"); //road name
in6.setAttribute("placeholder", "Road Nmae / Area / City ");
in6.setAttribute("id", "in6");
in6.setAttribute("type", "textarea");
var head3 = document.createElement("h2");
head3.textContent = "Contact";
var in1 = document.createElement("input"); //name
in1.setAttribute("placeholder", "Name");
in1.setAttribute("type", "text");
in1.setAttribute("id", "in1");
var in2 = document.createElement("input"); //email
in2.setAttribute("id", "in2");
in2.setAttribute("placeholder", "email");
in2.setAttribute("type", "email");
var in3 = document.createElement("input"); //phone no
in3.setAttribute("placeholder", "Phone no");
in3.setAttribute("type", "number");
in3.setAttribute("id", "in3");
var btt = document.createElement("button");//button
btt.textContent = "Ship to this Address";
form.append(div,head2,in5,in4,in6,head3,in1,in2,in3,btt);
document.querySelector("body").append(form);
// store in local store
document.querySelector("form").addEventListener("submit", address_add);
}
function closeForm()
{
console.log("Close");
var form_closing = document.querySelector("form");
form_closing.style.display = "none";
}
var Addpage = [];
function address_add(){
event.preventDefault();
var name = document.querySelector("#in1").value ;
var email = document.querySelector("#in2").value ;
var phone_no = document.querySelector("#in3").value ;
var address = document.querySelector("#in4").value ;
var pincode = document.querySelector("#in5").value ;
var road_no = document.querySelector("#in6").value ;
if(name === "" || email === "" || phone_no === "" || address === "" || pincode === "" || road_no === "")
{
alert("Fill all Details");
}
else
{
var page = {name:name, email:email, phone_no:phone_no, address:address, pincode:pincode, road_no:road_no};
Addpage.push(page);
localStorage.setItem("Address-data", JSON.stringify(Addpage));
console.log(Addpage);
var DisplayForm = JSON.parse(localStorage.getItem("Address-data")) || [];
DisplayForm.map(function(elem){
var Disname = document.createElement("h4");
Disname.textContent = elem.name;
var Disadd = document.createElement("p");
Disadd.setAttribute("id", "gotoadd");
Disadd.textContent = address;
var DisRoad = document.createElement("p");
DisRoad.textContent = road_no;
var DisNo = document.createElement("p");
DisNo.textContent = phone_no;
var DisButton = document.createElement("a");
DisButton.setAttribute("id", "gotopay");
DisButton.setAttribute("href", "payment.html");
DisButton.textContent = "Deliver Here -> ";
console.log(Disname)
document.querySelector("#display_Add").append(Disname,Disadd,DisRoad,DisNo,DisButton);
});
}
}
var dataFromCart = JSON.parse(localStorage.getItem("cartProducts")) || [];
// span will append number of products
var NumberofItems = localStorage.getItem("countitem")
document.querySelector("#Items").innerHTML = NumberofItems;
// span grand total
var GT = localStorage.getItem("cartvalue");
console.log(GT);
document.querySelector("#Grand_total").innerHTML = "₹ " + GT;
</script>
</html>