Files
madisonlinux/scripts/form.js
Cory Sanin 77ea3018c1
All checks were successful
App Image CI / Build app image (push) Successful in 37s
NPM Audit Check / Check NPM audit (push) Successful in -2m8s
create admin form
2025-11-01 00:31:52 -05:00

29 lines
959 B
JavaScript

document.addEventListener('DOMContentLoaded', function () {
const submit = document.getElementById('submitbtn');
submit.addEventListener('click', async () => {
submit.disabled = true;
const action = submit.parentElement.action;
try {
const resp = await fetch(action, {
method: 'POST',
body: JSON.stringify({
os: document.getElementById('os-select').value,
form: document.getElementById('form-select').value
}),
headers: {
"Content-Type": "application/json",
}
});
if (!resp.ok) {
throw new Error(`Response status: ${resp.status}`);
}
location.reload();
return false;
}
catch (error) {
console.error(error.message);
alert(error.message);
}
});
});