Custom Quote (Trial)

const form = document.querySelector('#quote-form'); form.addEventListener('submit', (e) => { e.preventDefault(); const name = document.querySelector('#name').value; const email = document.querySelector('#email').value; const length = parseFloat(document.querySelector('#length').value); const width = parseFloat(document.querySelector('#width').value); const height = parseFloat(document.querySelector('#height').value); const volume = length * width * height; const cost = volume * 0.5; // replace with your own cost calculation fetch('https://api.example.com/submit', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name, email }) }) .then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); }) .then(() => { // redirect to the quote page with volume and cost window.location.href = `/quote?volume=${volume}&cost=${cost}`; }) .catch(error => { console.error('Error submitting form', error); }); });