Message not sent, think it doesnt get form data? #9
Replies: 3 comments 3 replies
-
Please share your code directly here. |
Beta Was this translation helpful? Give feedback.
2 replies
-
function sendMail() {
var params = {
name: document.getElementById("name").value,
email: document.getElementById("email").value,
message: document.getElementById("description").value,
};
const serviceID = "service_myvalue";
const templateID = "template_myvalue";
emailjs.send(serviceID, templateID, params)
.then(res=>{
document.getElementById("name").value = "";
document.getElementById("email").value = "";
document.getElementById("description").value = "";
console.log(res);
alert("Your message sent successfully!!")
})
.catch(err=>console.log(err));
} ------- // -------------- HTML
<!-- Trigger/Open The Modal -->
<button id="myBtn">Contact form</button>
<!-- The Modal -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<h2>Message</h2>
</div>
<div class="modal-body">
<div id="content2">
<h2>Send an inquiry</h2>
<form>
<div>
<label for="name">Your name* :</label><br>
<input type="text" id="name" name="name" size="15" required maxlength="60"><br>
</div><br>
<div>
<label for="email">E-mail* :</label><br>
<input type="text" id="email" name="email" size="15" required maxlength="60"><br>
</div><br>
<div>
<label for="description">Message* :</label><br>
<textarea name="description" id="description" required></textarea>
</div><br>
<div>
<input type="submit" onclick="sendMail()" class="submit" name="skicka" value="Submit">
<input type="reset" value="Reset">
</div><br>
</form>
</div>
</div>
<div class="modal-footer">
<h3></h3>
</div>
</div>
</div> |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hello,
Simple answer Im not a programer so my understanding of this is very limited 🙂
Second off, Im not sure anymore that emailsjs actually is the problem. it may be my other not so well witten javascript functions blocking I think.
But I will take a look at .sendForm to see if that can solve my problem.
thank you for your help so far, I really apriciate it.
/Mike
…________________________________
Från: xr0master ***@***.***>
Skickat: den 27 maj 2023 10:24
Till: emailjs-com/help ***@***.***>
Kopia: Mikael-UXUI ***@***.***>; Author ***@***.***>
Ämne: Re: [emailjs-com/help] Message not sent, think it doesnt get form data? (Discussion #9)
It's hard to say that it doesn't work for you. But I can't help asking why you don't use the emailjs.sendForm method.
—
Reply to this email directly, view it on GitHub<#9 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/APZCAZ2UZYMJWMEUSXTRSBTXIG24BANCNFSM6AAAAAAYJS5YC4>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
xr0master
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
Can anyone see what I'm doing wrong? I want to take form data by callin sendMail() and send it to emailjs and use their free service to sent it to my gmail. I have excluded css here I dont think its relevant. Well Im no developer so I could be totaly wrong there. Im trying too combine w3schools modal and form tutorial with this tutorial Send Email using HTML + JavaScript (EmailJs Tutorial) https://www.youtube.com/watch?v=dgcYOm8n8ME
My html and js file.
my html.txt
myJS.txt
Thanks
Beta Was this translation helpful? Give feedback.
All reactions