generated from dwd/boilarplate-astro-tailwind
s1
This commit is contained in:
@@ -64,7 +64,6 @@ import Layout from "../layouts/Layout.astro";
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
|
||||
document.getElementById('formSection').addEventListener('submit', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -75,12 +74,12 @@ import Layout from "../layouts/Layout.astro";
|
||||
email: document.getElementById('email').value,
|
||||
message: document.getElementById('message').value
|
||||
},
|
||||
owner: 'owner_value',
|
||||
domain: 'domain_value',
|
||||
owner: 'Holy Wisdom Public School',
|
||||
domain: window.location.origin,
|
||||
referrer: document.referrer
|
||||
};
|
||||
|
||||
fetch('http://192.168.0.166:2053/v3/contact-form-processor/', {
|
||||
fetch('https://api.siliconpin.com/v3/contact-form-processor/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -90,96 +89,25 @@ import Layout from "../layouts/Layout.astro";
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
console.log('Data submitted successfully');
|
||||
// console.log('Data submitted successfully');
|
||||
if(data.success === true){
|
||||
document.getElementById('formSection').style.display = 'none';
|
||||
document.getElementById('thankYouSection').style.display = 'block';
|
||||
}
|
||||
console.log(data.success)
|
||||
} else {
|
||||
console.log('Error: ' + data.message);
|
||||
// console.log('Error: ' + data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
console.log('An error occurred while submitting the form');
|
||||
// console.error('Error:', error);
|
||||
// console.log('An error occurred while submitting the form');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
// document.addEventListener('DOMContentLoaded', function () {
|
||||
// const contactForm = document.getElementById('contactForm');
|
||||
// const formSection = document.getElementById('formSection');
|
||||
// const thankYouSection = document.getElementById('thankYouSection');
|
||||
// const nameInput = document.getElementById('name');
|
||||
// const emailInput = document.getElementById('email');
|
||||
// const phoneInput = document.getElementById('phone');
|
||||
// const messageInput = document.getElementById('message');
|
||||
|
||||
// contactForm.addEventListener('submit', async function (event) {
|
||||
// event.preventDefault();
|
||||
// let data = {
|
||||
// data:{
|
||||
// name: nameInput.value,
|
||||
// phone: phoneInput.value,
|
||||
// email: emailInput.value,
|
||||
// message: messageInput.value
|
||||
// },
|
||||
// owner: "Holly Wisdom Public School",
|
||||
// domain: window.location.origin,
|
||||
// referrer: "Holly Wisdom Public School"
|
||||
// }
|
||||
// console.log("Form Data", data)
|
||||
// const url = 'https://api.siliconpin.com/v3/contact-form-processor/';
|
||||
// try {
|
||||
// const response = await fetch(url, {
|
||||
// method: 'POST',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json'
|
||||
// },
|
||||
// body: JSON.stringify(data)
|
||||
// });
|
||||
// if (response.ok) {
|
||||
// console.log('Form data submitted successfully');
|
||||
// formSection.style.display = 'none';
|
||||
// thankYouSection.style.display = 'block';
|
||||
// } else {
|
||||
// console.error('Failed to submit form data');
|
||||
// }
|
||||
// } catch (error) {
|
||||
// console.error('An error occurred:', error);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
</script>
|
||||
<style>
|
||||
.gradintBack {
|
||||
background: linear-gradient(0deg, rgb(71, 174, 106) 0%, rgba(255, 255, 255) 40%);
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- function submitForm(){
|
||||
const formData = {
|
||||
data: {
|
||||
name: document.getElementById('name').value,
|
||||
email: document.getElementById('email').value,
|
||||
phone: document.getElementById('phone').value
|
||||
},
|
||||
owner: document.getElementById('owner').value,
|
||||
domain: document.getElementById('domain').value,
|
||||
referrer: document.getElementById('referrer').value
|
||||
};
|
||||
fetch(`http://192.168.0.166:2053/v3/contact-form/`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type' : 'application/json',
|
||||
},
|
||||
body: JSON.stringify(formData)
|
||||
})
|
||||
.then(response => {
|
||||
if(response.ok){
|
||||
console.log('Form submitted succesfully!');
|
||||
}else{
|
||||
console.log('Form submitted faild!');
|
||||
}
|
||||
})
|
||||
.then(error => {
|
||||
console.error('an error occoured', error);
|
||||
})
|
||||
} -->
|
||||
Reference in New Issue
Block a user