document.addEventListener("DOMContentLoaded", function () {
const jotformIframe = document.querySelector(".jotform-iframe"); // Select the iframe by class
if (jotformIframe) {
const currentPageUrl = new URL(window.location.href);
const currentPageParams = new URLSearchParams(currentPageUrl.search);
const iframeUrl = new URL(jotformIframe.src, window.location.origin);
const iframeParams = new URLSearchParams(iframeUrl.search);
// Merge parameters, keeping existing ones from iframe and adding/overwriting with the page's
currentPageParams.forEach((value, key) => {
iframeParams.set(key, value);
});
iframeUrl.search = iframeParams.toString(); // Update the iframe's query string
jotformIframe.src = iframeUrl.href; // Apply the updated URL to the iframe
}
});