表格提交后的通知

时间:2019-06-10 21:51:50

标签: javascript php html css ajax

我有一个将字段输入网站的表格。但是,一旦提交表单,我想发送一封单独​​的电子邮件,通知客户线索已经提交。

此表格收集客户信息,并馈送到存储所有客户信息的网站。表格的这一部分效果很好。我需要创建一个单独的动作或触发器,以将通知发送到电子邮件,以提醒我的客户端该应用程序已满。我尝试过的所有操作要么提交表单而不发送电子邮件,要么发送电子邮件而不提交信息。为了我的客户机密性,我已经更改了代码中的信息。

<form action="This is the domain that submits to the website but for client confidentiality i cannot display" method="POST" >

<input type=hidden name="oid" value="00D1U000001ANuJ">
<input type=hidden name="retURL" value="/pages/wholesale-application-thank-you">


      <label for="first_name">First Name</label><input  id="first_name" maxlength="40" name="first_name" size="20" type="text" class="input-full" placeholder="First Name"/><br>

      <label for="last_name" >Last Name</label><input  id="last_name" maxlength="80" name="last_name" size="20" type="text" class="input-full" placeholder="Last Name"/><br>

      <label for="title" >Title</label><input  id="title" maxlength="40" name="title" size="20" type="text" class="input-full" placeholder="Title"/><br>

      <label for="company" >Company</label><input  id="company" maxlength="40" name="company" size="20" type="text" class="input-full" placeholder="Company"/><br>

      <label for="URL" >Website</label><input  id="URL" maxlength="80" name="URL" size="20" type="text" class="input-full" placeholder="Website"/><br>

      <label for="email" >Email</label><input  id="email" maxlength="80" name="email" size="20" type="text" class="input-full" placeholder="Email"/><br>

      <label for="street" >Street</label><textarea name="street" class="input-full" placeholder="Street"></textarea><br>

      <label for="city" >City</label><input  id="city" maxlength="40" name="city" size="20" type="text" class="input-full" placeholder="City"/><br>

      <label for="zip" >Zip</label><input  id="zip" maxlength="20" name="zip" size="20" type="text" class="input-full" placeholder="Zip"/><br>

     <label for="state" >State/Province</label><input  id="state" maxlength="20" name="state" size="20" type="text" class="input-full" placeholder="State/Province"/><br>

     <label for="lead_source" >Lead Source</label><select  id="lead_source" name="lead_source" class="input-full"><option value="">--None--</option><option value="Events">Events</option>
     <option value="Facebook">Facebook</option>
     <option value="Google">Google</option>
     <option value="Instagram">Instagram</option>
     <option value="Retailer">Retailer</option>
     <option value="Social Media">Social Media</option>
     <option value="Third Party Site">Third Party Site</option>
     <option value="Trade Publication">Trade Publication</option>
     <option value="Trade Shows">Trade Shows</option>
     <option value="Twitter">Twitter</option>
     <option value="YouTube">YouTube</option>
     </select><br>


     <input type="submit" name="submit" >
</form>

1 个答案:

答案 0 :(得分:1)

您是否尝试过向表单添加submit事件监听器?遵循以下原则:

document.addEventListener('submit', (event) => {
    event.preventDefault();
    if (event.target.id === 'form-id') { // you'll need to give your form an id
        // do something like send an email
    };
};