Make a Gift

Quick App Embed Test

document.addEventListener(‘DOMContentLoaded’, function() {
async function fetchFormRequirements() {
const response = await fetch(‘https://www.spectrumemp.com/api/forms/requirements?IQS-API-KEY=b6173d35f6167307f9eba28143e2104cb4304e43&formID=48519’);
const data = await response.json();
return data;
}

function generateFormHTML(fields) {
let formHTML = ‘

‘;
fields.forEach(field => {
formHTML += ``;
formHTML += “;
});
formHTML += ‘‘;
formHTML += ‘

‘;
return formHTML;
}

async function renderForm() {
const formRequirements = await fetchFormRequirements();
const formHTML = generateFormHTML(formRequirements.fields);
document.getElementById(‘form-container’).innerHTML = formHTML;

document.getElementById(‘quickAppForm’).addEventListener(‘submit’, async function(event) {
event.preventDefault();
const form = event.target;
const formData = new FormData(form);
const data = {};
formData.forEach((value, key) => {
data[key] = value;
});

const response = await fetch(‘https://www.spectrumemp.com/api/forms/submit’, {
method: ‘POST’,
headers: {
‘Content-Type’: ‘application/json’,
‘IQS-API-KEY’: ‘b6173d35f6167307f9eba28143e2104cb4304e43’
},
body: JSON.stringify(data),
});

const result = await response.json();
console.log(result);
alert(‘Form submitted successfully!’);
});
}

renderForm();
});