Files
huntingclubroster/js/addDropdown.js
T

69 lines
1.8 KiB
JavaScript
Raw Normal View History

2026-10-18 17:01:36 +00:00
// ============
// Add Dropdown
// ============
$(document).ready(function () {
var $application = $("#APPLICATION_MNEMONIC").val(),
$sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}");
// -----------
// Save Button
// -----------
$(".btnSave").on("click", async function (e) {
2026-10-18 17:01:36 +00:00
e.preventDefault();
$("#addDropdown").submit();
});
// --------------
// Cancel Button.
// --------------
$(".btnCancel").on("click", async function () {
2026-10-18 17:01:36 +00:00
formSubmit({action: $sessionStorage.addDropdown});
});
// ---------------
// Validate Inputs
// ---------------
$("#addDropdown").submit(async function (e) {
e.preventDefault();
2026-10-18 17:01:36 +00:00
var dropdowntype_serial = $("#dropdowntype_serial").val(),
dropdown_value = $("#dropdown_value");
clearInputErrors();
dropdown_value.val(trimString(dropdown_value.val()));
if (isBlank(dropdown_value)) {
createInputError(dropdown_value, "Value is required");
return false;
}
if (await formPost({action: "Dropdowns.dropdownExists", dropdowntype_serial: dropdowntype_serial, dropdown_serial: 0, dropdown_value: dropdown_value.val()}) === true) {
2026-10-18 17:01:36 +00:00
createInputError(dropdown_value, "Value already exists");
return false;
}
e.preventDefault();
$.post("./", $(this).serialize())
.done(function () {
$sessionStorage.action = $sessionStorage.addDropdown || "";
$sessionStorage.toast = "Dropdown was Added";
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
formSubmit($sessionStorage);
});
});
});