-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpro.js
More file actions
37 lines (34 loc) · 1.4 KB
/
pro.js
File metadata and controls
37 lines (34 loc) · 1.4 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
function submitForm() {
const data = {
tv: {
brand: document.querySelector('input[name="tvBrand"]').value,
quantity: document.querySelector('input[name="tvQty"]').value
},
laptop: {
brand: document.querySelector('input[name="laptopBrand"]').value,
quantity: document.querySelector('input[name="laptopQty"]').value
},
mobile: {
brand: document.querySelector('input[name="mobileBrand"]').value,
quantity: document.querySelector('input[name="mobileQty"]').value
},
washingMachine: {
brand: document.querySelector('input[name="washBrand"]').value,
quantity: document.querySelector('input[name="washQty"]').value
},
others: {
brand: document.querySelector('input[name="otherBrand"]').value,
quantity: document.querySelector('input[name="otherQty"]').value
},
description: document.getElementById("description").value
};
fetch("http://localhost:3000/store-data", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data)
})
.then(res => res.json())
.then(res => alert(res.message || "Data submitted successfully!"))
.catch(err => alert("Error submitting data!"));
console.log("Submitted Data:", data);
}