-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
27 lines (24 loc) · 755 Bytes
/
Copy pathmain.js
File metadata and controls
27 lines (24 loc) · 755 Bytes
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
document.getElementById("itemForm").addEventListener("submit", function (e) {
e.preventDefault();
const type = document.getElementById("itemType").value;
const name = document.getElementById("itemName").value;
const description = document.getElementById("description").value;
const location = document.getElementById("location").value;
const contact = document.getElementById("contact").value;
const itemData = {
type,
name,
description,
location,
contact,
timestamp: Date.now()
};
db.ref("items").push(itemData)
.then(() => {
alert("Item submitted successfully!");
document.getElementById("itemForm").reset();
})
.catch((error) => {
alert("Error: " + error.message);
});
});