-
Notifications
You must be signed in to change notification settings - Fork 2
/
admin.js
60 lines (45 loc) · 1.61 KB
/
admin.js
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
document.querySelector("#showproduct").addEventListener("click", function () {
window.location.href = "adminviewprod.html";
});
// productpage
document.querySelector("#productpage").addEventListener("click", function () {
window.location.href = "product.html";
});
var arrofobj = JSON.parse(localStorage.getItem("lsproductdetails")) || [];
//console.log("Test");
document
.querySelector("#addproductfrm")
.addEventListener("submit", clicksubmitfunction);
function clicksubmitfunction(event) {
event.preventDefault();
console.log("Test");
//catch the value of inputs
var prodname = document.querySelector("#itemName").value;
var prodmrp = document.querySelector("#itemMrp").value;
var proddiscount = document.querySelector("#itemDiscount").value;
var prodcolor = document.querySelector("#itemColor").value;
var prodbrand = document.querySelector("#itemBrand").value;
var prodsize = document.querySelector("#itemSize").value;
var prodimage = document.querySelector("#itemimg").value;
var prodprice = prodmrp - (prodmrp * proddiscount) / 100;
prodprice = Math.floor(prodprice);
var obj = {
name: prodname,
imgURL: prodimage,
mrp: prodmrp,
discount: proddiscount,
price: prodprice,
color_family: prodcolor,
brand: prodbrand,
size: prodsize,
};
//console.log(obj);
arrofobj.push(obj);
//console.log(arrofobj);
localStorage.setItem("lsproductdetails", JSON.stringify(arrofobj));
}
var orderdetails = document.querySelector("#orderdetails");
orderdetails.addEventListener('click',orderData);
function orderData(){
window.location.href = "adminorder.html";
}