Ruben Hernandez
Ruben Hernandez

Reputation: 9

Notification after Form Submit

I have a form that feeds fields into a website. But i would like to send a separate email, once my form has been submitted, to notify the client that a lead has been submitted.

This form collects customer information and is fed to a website where all the client information is stored. That part of the form works perfectly. I need to create a separate action, or a trigger, that sends a notification to an email, alerting my client that the application has been filled. Everything that I have tried either submits the form without sending an email, or sends an email without submitting the information. I have changed information in the code for my clients confidentiality.

<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>

Upvotes: 0

Views: 1693

Answers (1)

davidfloyd91
davidfloyd91

Reputation: 517

Have you tried adding a submit event listener to the form? Something along these lines:

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
    };
};

Upvotes: 1

Related Questions