如何使用javascript将表单联系人发送到电子邮件?

时间:2017-05-11 14:44:54

标签: javascript html wordpress

我尝试将填写在表单中的数据发送到我的电子邮件中: 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>

我找到了这些

  1. how-to-send-an-email-from-javascript
  2. sending-emails-with-javascript
  3. 但它对mge不起作用。我使用wordpress创建自己的网站。我该如何解决这个问题?

0 个答案:

没有答案