I’m trying to send the data filled in a form to my email:
form.html:

    <form role="form" name="contact_form">
  <div class="col-xs-4">
    <div class="form-group">
      <input type="text" class="form-control" id="input_name" name="Name" placeholder="Name">
    </div>
    <div class="form-group">
      <input type="email" class="form-control" id="input_email" name="Email" placeholder="Email">
    </div>
    <div class="form-group">
      <input type="tel" class="form-control" id="input_phone" name="Phone" placeholder="Phone">
    </div>
    <div class="form-group">
      <input type="tel" class="form-control" id="input_location" name="Location" placeholder="Location">
    </div>
  </div>
  <div class="col-xs-6">
    <div class="form-group">
      <textarea class="form-control"  id="contact_comment" name="Comment" placeholder="



Details or comments?" rows="10"></textarea>
    </div>
  </div>
<div class="col-xs-2">
    <div class="form-group">
      <button id="submit_button"type="submit" class="btn btn-primary" onclick="submit_comment()">Submit</button>
    </div>
  </div>
</form>

script.js:

<script>
function sendMail(str) {
    var link = "mailto:slim.hmidi1@gmail.com" + "&subject=" + escape("This is my subject") + "&body=" + escape(str);
    location.href = link;
}
function submit_comment() {
var name = document.forms["contact_form"]["Name"].value;
var Email = document.forms["contact_form"]["Email"].value;
var Phone = document.forms["contact_form"]["Phone"].value;
var Location = document.forms["contact_form"]["Location"].value;
var Comment = document.forms["contact_form"]["Location"].value;
if((name !="") && (Email !="") && (Phone !="") && (Location !="") && (Comment !="")) {
   sendMail("HELLO");
}
}
</script>

I found these

  1. how-to-send-an-email-from-javascript
  2. sending-emails-with-javascript

But it doesn’t work for mge.I’m using wordpress to create my own website.How can I fix that?

Read more here: how can I send form contact to email using javascript?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: