<form id="myForm" action="thanks.html" method="get">
const form = document.getElementById("myForm");
const elements = form.elements;
var firstName = elements["first-name"]
var lastName = elements["last-name"]
var email = elements["email"]
var phone = elements["phone"]
var location;
var service;
var referrer = elements.referrer;
var availability = elements.availability
form.addEventListener("submit", (event) => {
event.preventDefault();
console.log("clicked")
elements.location.forEach(element => {
if (element.checked) {
location = element
}
});
elements["detail-type"].forEach(element => {
if (element.checked) {
service = element
}
});
var info = {
firstName: firstName.value,
lastName: lastName.value,
email: email.value,
phone: phone.value,
location: location.value,
service: service.value,
referrer: referrer.value,
availability: availability.value,
}
console.log(info)
emailjs.send("service_ldwpana","template_f8di4e5", info).then((e) => {
alert("done")
});
});
Here is the code for the html of the form and javascript. Can anyone help me out?
const form = document.getElementById("myForm");
const elements = form.elements;
var firstName = elements["first-name"]
var lastName = elements["last-name"]
var email = elements["email"]
var phone = elements["phone"]
var location;
var service;
var referrer = elements.referrer;
var availability = elements.availability
form.addEventListener("submit", (event) => {
event.preventDefault();
console.log("clicked")
elements.location.forEach(element => {
if (element.checked) {
location = element
}
});
elements["detail-type"].forEach(element => {
if (element.checked) {
service = element
}
});
var info = {
firstName: firstName.value,
lastName: lastName.value,
email: email.value,
phone: phone.value,
location: location.value,
service: service.value,
referrer: referrer.value,
availability: availability.value,
}
console.log(info)
emailjs.send("service_ldwpana","template_f8di4e5", info).then((e) => {
alert("done")
});
});
Here is the code for the html of the form and javascript. Can anyone help me out?