console.log('✅ Register popup JS loaded');
document.addEventListener('change', function (e) {
const el = e.target;
// Must be a radio input
if (!el || el.type !== 'radio') return;
// Must be this WPForms field (ID 21)
if (el.name !== 'wpforms[fields][21]') return;
// Must be this form (ID 20345)
const form = el.closest('form.wpforms-form');
if (!form || form.id !== 'wpforms-form-20345') return;
const value = (el.value || '').trim().toLowerCase();
console.log('radio changed:', el.name, value);
if (value !== 'no') return;
// Popup ID from your screenshot
const POPUP_ID = 20348;
if (window.elementorProFrontend?.modules?.popup?.showPopup) {
console.log('✅ Opening popup', POPUP_ID);
elementorProFrontend.modules.popup.showPopup({ id: POPUP_ID });
} else {
console.log('❌ Elementor popup module not found');
}
});