diff --git a/site/public/order/dot-compliance/index.html b/site/public/order/dot-compliance/index.html index 12682e3..919d646 100644 --- a/site/public/order/dot-compliance/index.html +++ b/site/public/order/dot-compliance/index.html @@ -438,13 +438,15 @@ document.querySelectorAll("input[data-bundle]").forEach(function(bundleCb) { // (optional — skip for simplicity, the bundle is always a better deal) // Checkbox change → update total -var checkboxes = document.querySelectorAll("input[data-slug]"); var totalSection = document.getElementById("pw-total-section"); var totalRows = document.getElementById("pw-total-rows"); // Non-discountable slugs (passthrough costs) var nonDiscountable = {"dot-drug-alcohol": true, "boc3-filing": true, "mc-authority": true}; +// Re-query checkboxes each time (state services added dynamically) +function getCheckboxes() { return document.querySelectorAll("input[data-slug]"); } + // Cached discount info var activeDiscount = null; function fetchDiscount() { @@ -467,7 +469,7 @@ function updateTotal() { var svcTotal = 0; var govTotal = 0; var discountable = 0; - checkboxes.forEach(function(cb) { + getCheckboxes().forEach(function(cb) { if (cb.checked) { var price = parseInt(cb.dataset.price) || 0; var gov = parseInt(cb.dataset.govfee) || 0; @@ -489,7 +491,7 @@ function updateTotal() { // Build itemized list var html = ''; - checkboxes.forEach(function(cb) { + getCheckboxes().forEach(function(cb) { if (!cb.checked) return; var price = parseInt(cb.dataset.price) || 0; var gov = parseInt(cb.dataset.govfee) || 0; @@ -521,7 +523,9 @@ function updateTotal() { totalRows.innerHTML = html; } -checkboxes.forEach(function(cb) { cb.addEventListener("change", updateTotal); }); +getCheckboxes().forEach(function(cb) { cb.addEventListener("change", updateTotal); }); +// Also listen for changes on dynamically shown state services +document.addEventListener("change", function(e) { if (e.target.matches && e.target.matches("input[data-slug]")) updateTotal(); }); // Pre-check services from URL var preSelect = (params.get("services") || "").split(",").filter(Boolean); @@ -535,7 +539,7 @@ if (preSelect.length) updateTotal(); document.getElementById("pw-batch-form").addEventListener("submit", function(e) { e.preventDefault(); var selected = []; - checkboxes.forEach(function(cb) { if (cb.checked) selected.push(cb.dataset.slug); }); + getCheckboxes().forEach(function(cb) { if (cb.checked) selected.push(cb.dataset.slug); }); if (selected.length === 0) { alert("Please select at least one service."); return; } if (!document.getElementById("pw-engage").checked) { alert("Please accept the authorization terms."); return; }