document.addEventListener("DOMContentLoaded", function () { var path = window.location.pathname; if (path.indexOf("/donate") === -1 && path.indexOf("/membership") === -1) return; var btn = document.querySelector( 'input[type="submit"], button[type="submit"], .gform_button, .ginput_container input[type="submit"]' ); var form = document.querySelector("form"); if (!btn || !form) return; form.addEventListener("submit", function (e) { e.preventDefault(); e.stopPropagation(); function getVal(name) { var el = form.querySelector('[name="' + name + '"]'); if (!el) return ""; if (el.tagName === "SELECT") return el.options[el.selectedIndex]?.text || el.value; return el.value ? el.value.trim() : ""; } function getCheck(name) { var el = form.querySelector('[name="' + name + '"]'); return el ? el.checked : false; } var source = path.indexOf("/membership") !== -1 ? "Membership" : "Donate"; var payload = { contribution: getVal("contribution"), email: getVal("email"), organization_giving: getCheck("organization_giving"), organization_name: getVal("organization_name"), organization_phone: getVal("organization_phone"), organization_email: getVal("organization_email"), organization_address: getVal("organization_address"), organization_city: getVal("organization_city"), organization_state: getVal("organization_state"), organization_zip: getVal("organization_zip"), organization_country: getVal("organization_country"), prefix: getVal("prefix"), first_name: getVal("first_name"), last_name: getVal("last_name"), suffix: getVal("suffix"), address: getVal("address"), city: getVal("city"), state: getVal("state"), zip: getVal("zip"), country: getVal("country"), mobile: getVal("mobile"), field_33: getVal("field_33"), field_33_1: getVal("field_33_1"), field_17: getVal("field_17"), billing_first_name: getVal("billing_first_name"), billing_middle_name: getVal("billing_middle_name"), billing_last_name: getVal("billing_last_name"), billing_address: getVal("billing_address"), billing_city: getVal("billing_city"), billing_state: getVal("billing_state"), billing_zip: getVal("billing_zip"), billing_country: getVal("billing_country"), stay_connected: getCheck("stay_connected"), billingcheck: getCheck("billingcheck"), service_policy: getCheck("service_policy"), source: source }; console.log("Sending payload:", payload); fetch("https://api.ti2.in/vrynoapi/alcohol/donate_insert.php", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) }) .then(function (res) { return res.json(); }) .then(function (data) { console.log("API success:", data); form.reset(); if (typeof grecaptcha !== "undefined") grecaptcha.reset(); var msg = document.createElement("div"); msg.style.cssText = "background:#d1fae5;color:#065f46;padding:14px 20px;border-radius:8px;margin:16px 0;font-size:15px;font-weight:500;"; msg.textContent = "Thank you! Your submission has been received successfully."; form.parentNode.insertBefore(msg, form); setTimeout(function () { if (msg.parentNode) msg.parentNode.removeChild(msg); }, 5000); }) .catch(function (err) { console.error("API error:", err); alert("Something went wrong. Please try again."); }); }); }); Skip to main content

Alcohol Justice

15 Nov 2022

Marijuana Moment