42 lines
1.5 KiB
JavaScript
42 lines
1.5 KiB
JavaScript
function addToCart(product) {
|
|
alert(product + " has been added to your cart. We are still setting up our full checkout system!");
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const inquiryForm = document.getElementById('inquiryForm');
|
|
if (inquiryForm) {
|
|
inquiryForm.addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
const formData = new FormData(this);
|
|
const submitBtn = this.querySelector('button[type="submit"]');
|
|
|
|
submitBtn.disabled = true;
|
|
submitBtn.textContent = 'Sending...';
|
|
|
|
fetch(this.action, {
|
|
method: 'POST',
|
|
body: formData
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
alert('Thank you! We have received your inquiry.');
|
|
const modal = bootstrap.Modal.getInstance(document.getElementById('inquiryModal'));
|
|
modal.hide();
|
|
inquiryForm.reset();
|
|
} else {
|
|
alert('Error: ' + data.error);
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
alert('There was an error sending your inquiry.');
|
|
})
|
|
.finally(() => {
|
|
submitBtn.disabled = false;
|
|
submitBtn.textContent = 'Send Inquiry';
|
|
});
|
|
});
|
|
}
|
|
});
|