-
Notifications
You must be signed in to change notification settings - Fork 0
/
parkings.js
59 lines (49 loc) · 2.01 KB
/
parkings.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
const navbar = document.querySelectorAll("nav div ul li a");
const sections = document.querySelectorAll(".section");
navbar.forEach((elemnt) => {
elemnt.addEventListener("click", () => {
// Hide all sections first
sections.forEach(section => {
section.style.display = "none";
});
// Remove 'active' class from all navbar items
navbar.forEach(item => {
item.classList.remove("active");
});
// Show the corresponding section based on the clicked navbar item
switch (elemnt.textContent) {
case "Home":
document.getElementById("home").style.display = "block";
//document.getElementById("map").style.display = "block";
break;
case "User Guide":
document.getElementById("search").style.display = "block";
break;
case "Add Parking":
document.getElementById("add-parking").style.display = "block";
break;
case "Contact":
document.getElementById("contact").style.display = "block";
break;
}
// Add 'active' class to the clicked navbar item
elemnt.classList.add("active");
});
});
// Add an event listener for form submission
document.getElementById("parkingForm").addEventListener("submit", function(event) {
event.preventDefault(); // Prevent the form from submitting in the traditional way
// Get the value from the input field
const locationUrl = document.getElementById("locationUrl").value;
if (locationUrl) {
// Create a new list item and set it to be invisible
const listItem = document.createElement("li");
listItem.textContent = locationUrl;
listItem.style.display = "none"; // Hide the new list item
// Add the new list item to the list
document.getElementById("locationList").appendChild(listItem);
// Optionally, you can clear the input field
document.getElementById("locationUrl").value = "Thank you ! 🙌";
setTimeout( (() => {document.getElementById("locationUrl").value = ""}),3000);
}
});