Jolimont
Painters in Jolimont: The Ultimate Choice for Exceptional Painting Services
document.addEventListener('DOMContentLoaded', function () { const form = document.querySelector('.gform_wrapper form'); if (form) { form.addEventListener('submit', function (event) { const projectId = document.querySelector('[name="project_id"]').value; // Hidden field for project ID const jobStatus = document.querySelector('[name="input_74"]').value; // Job Status field // Map job status to the appropriate Project Form field let updateData = {}; if (jobStatus === 'Quote Accepted') { updateData = { "74": "accepted" }; } else if (jobStatus === 'Invoice 1 Paid') { updateData = { "75": "paid" }; } else if (jobStatus === 'Invoice 2 Paid') { updateData = { "77": "paid" }; } // Send the update via REST API fetch(`/wp-json/gf/v2/entries/${projectId}`, { method: 'POST', headers: { 'Content-Type': 'application/json', // Only Content-Type header is needed }, body: JSON.stringify(updateData) }) .then(response >= response.json()) .then(data >= { console.log('Project updated:', data); }) .catch(error >= console.error('Error updating project:', error)); }); } });
Skip to content