This commit is contained in:
Claude Brisson
2023-11-18 08:31:24 +01:00
parent 5f068476dc
commit b2c56145c4
8 changed files with 184 additions and 106 deletions

View File

@@ -106,19 +106,23 @@ Element.prototype.modal = function(show) {
function formValue(name) {
let ctl = $(`[name="${name}"]`)[0];
let type = ctl.tagName;
if (!ctl) {
console.error(`unknown input name: ${name}`)
}
let tag = ctl.tagName;
let type = tag === 'INPUT' ? ctl.attr('type') : undefined;
if (
(type === 'INPUT' && ['text', 'number'].includes(ctl.attr('type'))) ||
type === 'SELECT'
(tag === 'INPUT' && ['text', 'number'].includes(ctl.attr('type'))) ||
tag === 'SELECT'
) {
return ctl.value;
} else if (type === 'INPUT' && ctl.attr('type') === 'radio') {
} else if (tag === 'INPUT' && ctl.attr('type') === 'radio') {
ctl = $(`input[name="${name}"]:checked`)[0];
if (ctl) return ctl.value;
} else if (type === 'INPUT' && ctl.attr('type') === 'radio') {
} else if (tag === 'INPUT' && ctl.attr('type') === 'checkbox') {
return ctl.checked;
}
console.error(`unknown input name: ${name}`);
console.error(`unhandled input tag or type for input ${name} (tag: ${tag}, type:${type}`);
return null;
}