-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
123 lines (101 loc) · 4.02 KB
/
index.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
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Style or stolen shop</title>
</head>
<body>
<div id="addProduct">
<form action="action" >
<legend>New product</legend>
<label>Name</label>
<input type="Text" id="nam" maxlength="20" tabindex="2" required>
<br>
<label>Price</label>
<input type="number" id="price" min="1" max="100000" value="1" required>
<br>
<label>Special price</label>
<input type="number" id="sPric" min="1" max="1000000" value="1" >
<br>
<label>Description</label>
<br>
<textarea rows="10" id="desc" cols="45" name="text"></textarea>
<br>
<label>Photo</label>
<input type="url" name="photo">
<br>
<label>Catgory</label>
<input type="number" id="category" min="1" max="100000" value="1" required>
<br>
<input id="add" onclick="addProduct()" type="submit" value="Add new Product">
</form>
</div>
<div id="addCategory">
<form action="action" >
<legend>New Categorry</legend>
<label>Name</label>
<input type="Text" id="namCat" maxlength="20" tabindex="2" required>
<br>
<input id="addCat" onclick="addCategory()" type="submit" value="Add new Categorry">
</form>
</div>
</body>
<script type="text/javascript">
function addProduct(){
var final = "";
// var name=document.getElementById("nam").value;
//final += "token=fjdzHdL7_TK1mZUShiQd";
final += "&name=" + document.getElementById("namCat").value;
var saveData = $.ajax({
type: 'POST',
url: 'http://localhost:8080/addProduct',
data: final,
dataType: "text",
success: function(data)
{
console.log(data); // show response from the php script.
},
error: function(xhr){
console.log("An error occured: " + xhr.status + " " + xhr.statusText);
},
});
event.preventDefault();
}
function addCategory(){
var final = "";
// var name=document.getElementById("nam").value;
//final += "token=fjdzHdL7_TK1mZUShiQd";
final += "&name=" + document.getElementById("nam").value + "&price=" + document.getElementById("price").value + "&sPric=" + document.getElementById("desc").value+ElementById("photo").value+ElementById("category").value;
var saveData = $.ajax({
type: 'POST',
url: 'http://localhost:8080/addCategory',
data: final,
dataType: "text",
success: function(data)
{
console.log(data); // show response from the php script.
},
error: function(xhr){
console.log("An error occured: " + xhr.status + " " + xhr.statusText);
},
});
event.preventDefault();
}
let _bagProduct = ({
id,
name,
image_url,
description,
price,
special_price,
category,
}) => {
let $product = $(` <div class="bagProd" data-product-id="${id}" id="inB+${id}">`);
$product.append($(`<span class="name">`).text(name));
$product.append($(`<br>`));
$product.append($(`<input id="quan+${id}" class="" min="1" max="100000" value="${category}"> <hr>`));
return $product;
};
module.exports = _bagProduct;
</script>
</html>