41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
|
|
document.addEventListener("DOMContentLoaded", () =>
|
|
{
|
|
fetch("getIncidents.php").then(res => res.json().then(json =>
|
|
{
|
|
if(json.message === "ok")
|
|
{
|
|
let body = "";
|
|
for (const incident of json.incidents)
|
|
{
|
|
body += `<option value="${incident.Incident_ID}">${incident.Incident_Report} — ${incident.Incident_Date}</option>`;
|
|
}
|
|
document.querySelector("#incident").innerHTML = body;
|
|
}
|
|
}));
|
|
|
|
});
|
|
|
|
document.querySelector("#addFineForm").addEventListener("submit", e =>
|
|
{
|
|
e.preventDefault();
|
|
let formData = new FormData();
|
|
formData.append("amount", document.querySelector("#amount").value);
|
|
formData.append("points", document.querySelector("#points").value);
|
|
formData.append("incident", document.querySelector("#incident").value)
|
|
|
|
fetch("addFine.php", {
|
|
method: "POST",
|
|
body: formData
|
|
}).then(res => res.json().then(json => {
|
|
if(json.message === "ok")
|
|
{
|
|
alert("Fine added successfully");
|
|
}
|
|
else
|
|
{
|
|
alert("Error adding fine");
|
|
}
|
|
|
|
}));
|
|
}); |