试图写一个JavaScript来通过电子邮件发送我的HTML表格

时间:2018-08-14 07:54:02

标签: javascript html css

嗨,我已经编写了CSS代码和HTML,但我一直在努力将其发送到IE11中,我已经看到了几种方法使之成为可能,并想知道哪种方法最好。这是我编写的代码,请帮忙,虽然很长,但是到目前为止,它仍然有效。如果我告诉你我的未来取决于这个,那会有所帮助

div {
  height: 14cm;
  width: 10cm;
}

body {
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

input[type=text],
select,
textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
  margin-top: 6px;
  margin-bottom: 16px;
  resize: vertical;
}

input[type=submit] {
  background-color: #4CAF50;
  color: white;
  padding: 12px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

input[type=submit]:hover {
  background-color: #45a049;
}

input[type=Reset] {
  background-color: #4CAF50;
  color: white;
  padding: 12px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

input[type=Reset]:hover {
  background-color: #45a049;
}

.container {
  border-radius: 5px;
  background-color: #f2f2f2;
  padding: 20px;
}
<h3>eKFI Guidance Tracker</h3>


enter code here

<div class="container">
  <form action="mailto:hard.up@pleasehelp.co.uk?subject=eKFI%20form%20submission" method="post" enctype="text/plain" <label for="MEC">MEC Name</label>
    <input type="text" id="MEC" name="MEC" placeholder="MEC Name">

    <label for="FNumber">F-Number</label>
    <input type="text" id="FNumber" name="Customer Number" placeholder="Enter customer F-Number...">

    <label for="Platform">Platform</label>
    <select id="Platform" name="Platform">
      <option value=""></option>
      <option value="Iphone/Ipad">Iphone/Ipad</option>
      <option value="PC/Laptop">PC/Laptop</option>
      <option value="Android">Android</option>
    </select>

    <label for="Notes">Notes</label>
    <textarea id="Notes" name="Notes" placeholder="Write something.." style="height:60px"></textarea>

    <input type="submit" value="Submit">
    <input type="Reset" value="Reset">
  </form>
</div>

提前感谢,将对您有很大帮助

2 个答案:

答案 0 :(得分:1)

我认为无法通过javascript发送电子邮件,因为它是基于客户端的语言。如果您不想“重新加载页面”,或者仅可以使用PHP重新加载页面,则可以使用Ajax + PHP发送它,如this link所示。 (您也可以在JavaScript课程的本页上找到AJAX教程)。 另外,请查看this的答案。

答案 1 :(得分:0)

好吧。我宁愿使用PHP来执行此操作。就像@Comp所说的那样,javascript是一种基于客户端的语言,并非用于/不用于发送邮件和东西。 Ajax也是一个很好的机会。但我更喜欢使用效果最好的PHP:)