Upload 3 files
Browse files- script.js +24 -21
- states-lgas.js +27 -32
- style.css +28 -53
script.js
CHANGED
|
@@ -1,27 +1,30 @@
|
|
| 1 |
-
document.addEventListener("DOMContentLoaded", function () {
|
| 2 |
-
const form = document.getElementById("registrationForm");
|
| 3 |
|
| 4 |
-
|
| 5 |
-
e.preventDefault();
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
}
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
alert("An error occurred. Please try again.");
|
| 25 |
-
}
|
| 26 |
-
});
|
| 27 |
});
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
+
// script.js - Handles API calls and DOM updates
|
|
|
|
| 3 |
|
| 4 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 5 |
+
const form = document.getElementById('loginForm');
|
| 6 |
+
const output = document.getElementById('output');
|
| 7 |
|
| 8 |
+
if (form) {
|
| 9 |
+
form.addEventListener('submit', async function(e) {
|
| 10 |
+
e.preventDefault();
|
| 11 |
+
const username = document.getElementById('username').value;
|
| 12 |
+
const password = document.getElementById('password').value;
|
| 13 |
|
| 14 |
+
output.textContent = 'Checking...';
|
| 15 |
+
|
| 16 |
+
try {
|
| 17 |
+
const response = await fetch('/api/check_user', {
|
| 18 |
+
method: 'POST',
|
| 19 |
+
headers: {'Content-Type': 'application/json'},
|
| 20 |
+
body: JSON.stringify({username, password})
|
| 21 |
+
});
|
| 22 |
+
const data = await response.json();
|
| 23 |
+
output.textContent = data.message || JSON.stringify(data);
|
| 24 |
+
} catch (error) {
|
| 25 |
+
console.error(error);
|
| 26 |
+
output.textContent = 'Error connecting to server';
|
| 27 |
}
|
| 28 |
+
});
|
| 29 |
+
}
|
|
|
|
|
|
|
|
|
|
| 30 |
});
|
states-lgas.js
CHANGED
|
@@ -1,38 +1,33 @@
|
|
| 1 |
|
| 2 |
-
|
| 3 |
-
"Abia": ["Aba North", "Aba South", "Arochukwu", "Bende", "Ikwuano", "Isiala Ngwa North", "Isiala Ngwa South", "Isuikwuato", "Obi Ngwa", "Ohafia", "Osisioma", "Ugwunagbo", "Ukwa East", "Ukwa West", "Umuahia North", "Umuahia South", "Umu Nneochi"],
|
| 4 |
-
"Adamawa": ["Demsa", "Fufore", "Ganye", "Girei", "Gombi", "Guyuk", "Hong", "Jada", "Lamurde", "Madagali", "Maiha", "Mayo-Belwa", "Michika", "Mubi North", "Mubi South", "Numan", "Shelleng", "Song", "Toungo", "Yola North", "Yola South"],
|
| 5 |
-
"Akwa Ibom": ["Abak", "Eastern Obolo", "Eket", "Esit Eket", "Essien Udim", "Etim Ekpo", "Etinan", "Ibeno", "Ibesikpo Asutan", "Ibiono-Ibom", "Ika", "Ikono", "Ikot Abasi", "Ikot Ekpene", "Ini", "Itu", "Mbo", "Mkpat-Enin", "Nsit-Atai", "Nsit-Ibom", "Nsit-Ubium", "Obot Akara", "Okobo", "Onna", "Oron", "Oruk Anam", "Udung-Uko", "Ukanafun", "Uruan", "Urue-Offong/Oruko", "Uyo"],
|
| 6 |
-
"Anambra": ["Aguata", "Anambra East", "Anambra West", "Anaocha", "Awka North", "Awka South", "Ayamelum", "Dunukofia", "Ekwusigo", "Idemili North", "Idemili South", "Ihiala", "Njikoka", "Nnewi North", "Nnewi South", "Ogbaru", "Onitsha North", "Onitsha South", "Orumba North", "Orumba South", "Oyi"]
|
| 7 |
-
// You can continue to add all the other states here following the same format...
|
| 8 |
-
};
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
const option = document.createElement("option");
|
| 15 |
-
option.value = state;
|
| 16 |
-
option.textContent = state;
|
| 17 |
-
stateSelect.appendChild(option);
|
| 18 |
-
}
|
| 19 |
};
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
const lgaSelect = document.getElementById("lga");
|
| 25 |
-
const selectedState = stateSelect.value;
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
+
// states-lgas.js - Handles Nigerian states and LGAs dropdown population
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
const statesAndLgas = {
|
| 5 |
+
'Lagos': ['Ikeja', 'Epe', 'Ikorodu'],
|
| 6 |
+
'Kano': ['Nasarawa', 'Tarauni', 'Dala'],
|
| 7 |
+
'FCT': ['Gwagwalada', 'Abaji', 'Bwari'],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
};
|
| 9 |
|
| 10 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 11 |
+
const stateSelect = document.getElementById('state');
|
| 12 |
+
const lgaSelect = document.getElementById('lga');
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
if (stateSelect && lgaSelect) {
|
| 15 |
+
for (const state in statesAndLgas) {
|
| 16 |
+
const option = document.createElement('option');
|
| 17 |
+
option.value = state;
|
| 18 |
+
option.textContent = state;
|
| 19 |
+
stateSelect.appendChild(option);
|
| 20 |
+
}
|
| 21 |
|
| 22 |
+
stateSelect.addEventListener('change', function() {
|
| 23 |
+
const lgas = statesAndLgas[this.value] || [];
|
| 24 |
+
lgaSelect.innerHTML = '';
|
| 25 |
+
lgas.forEach(lga => {
|
| 26 |
+
const option = document.createElement('option');
|
| 27 |
+
option.value = lga;
|
| 28 |
+
option.textContent = lga;
|
| 29 |
+
lgaSelect.appendChild(option);
|
| 30 |
+
});
|
| 31 |
+
});
|
| 32 |
+
}
|
| 33 |
+
});
|
style.css
CHANGED
|
@@ -1,64 +1,39 @@
|
|
| 1 |
|
|
|
|
| 2 |
body {
|
| 3 |
-
font-family:
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
background: #f4f4f9;
|
| 7 |
-
color: #333;
|
| 8 |
-
}
|
| 9 |
-
header {
|
| 10 |
-
background: #005792;
|
| 11 |
-
color: white;
|
| 12 |
-
padding: 1rem;
|
| 13 |
-
text-align: center;
|
| 14 |
-
}
|
| 15 |
-
nav ul {
|
| 16 |
-
list-style: none;
|
| 17 |
-
display: flex;
|
| 18 |
-
justify-content: center;
|
| 19 |
-
padding: 0;
|
| 20 |
-
}
|
| 21 |
-
nav ul li {
|
| 22 |
-
margin: 0 15px;
|
| 23 |
-
}
|
| 24 |
-
nav ul li a {
|
| 25 |
-
color: white;
|
| 26 |
-
text-decoration: none;
|
| 27 |
-
}
|
| 28 |
-
.hero {
|
| 29 |
-
padding: 2rem;
|
| 30 |
-
background: #d1e7ff;
|
| 31 |
-
text-align: center;
|
| 32 |
-
}
|
| 33 |
-
.form-section, .info-section {
|
| 34 |
-
padding: 2rem;
|
| 35 |
}
|
|
|
|
| 36 |
form {
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
| 38 |
margin: auto;
|
| 39 |
-
|
| 40 |
-
flex-direction: column;
|
| 41 |
}
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
| 48 |
}
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
font-size: 1rem;
|
| 53 |
-
background-color: #005792;
|
| 54 |
color: white;
|
| 55 |
border: none;
|
| 56 |
-
cursor: pointer;
|
| 57 |
-
border-radius: 5px;
|
| 58 |
}
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
| 64 |
}
|
|
|
|
| 1 |
|
| 2 |
+
/* style.css - Basic styling */
|
| 3 |
body {
|
| 4 |
+
font-family: sans-serif;
|
| 5 |
+
padding: 20px;
|
| 6 |
+
background: #f5f5f5;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
}
|
| 8 |
+
|
| 9 |
form {
|
| 10 |
+
background: #fff;
|
| 11 |
+
padding: 15px;
|
| 12 |
+
border-radius: 8px;
|
| 13 |
+
max-width: 300px;
|
| 14 |
margin: auto;
|
| 15 |
+
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
|
|
|
| 16 |
}
|
| 17 |
+
|
| 18 |
+
input, select, button {
|
| 19 |
+
width: 100%;
|
| 20 |
+
padding: 8px;
|
| 21 |
+
margin: 5px 0;
|
| 22 |
+
border-radius: 5px;
|
| 23 |
+
border: 1px solid #ddd;
|
| 24 |
}
|
| 25 |
+
|
| 26 |
+
button {
|
| 27 |
+
background: #007bff;
|
|
|
|
|
|
|
| 28 |
color: white;
|
| 29 |
border: none;
|
|
|
|
|
|
|
| 30 |
}
|
| 31 |
+
|
| 32 |
+
button:hover {
|
| 33 |
+
background: #0056b3;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
#output {
|
| 37 |
+
margin-top: 10px;
|
| 38 |
+
font-weight: bold;
|
| 39 |
}
|