Fix shirt size for monthly an annual renew

This commit is contained in:
Ben Sturmfels 2024-05-08 18:05:27 +10:00
parent 0d25e1a87d
commit fb690c1676
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0

View file

@ -8,11 +8,11 @@
'use strict';
function qs (selector, parent) {
return document.querySelector(selector);
return parent ? parent.querySelector(selector) : document.querySelector(selector);
}
function qsa (selector, parent) {
return document.querySelectorAll(selector);
return parent ? parent.querySelectorAll(selector) : document.querySelectorAll(selector);
}
function hide(el) {
@ -33,13 +33,14 @@ function showVideoInnerHTML (event) {
function toggleShirtSize (form) {
let wantShirt = form.elements['on0'].value === 'wantGiftYes';
let shirtSizeSelector = form.elements['os0'];
shirtSizeSelector.disabled = !wantShirt;
let shirtSizeRow = qs('.t-shirt-size-selector', form);
let shirtSizeSelect = form.elements['os0'];
shirtSizeSelect.disabled = !wantShirt;
form.elements['no_shipping'].value = wantShirt ? '2' : '0';
if (wantShirt) {
show(shirtSizeSelector);
show(shirtSizeRow);
} else {
hide(shirtSizeSelector);
hide(shirtSizeRow);
}
}