0

I am trying to get the contents of a form to send in an email. Below is the code but it does not add the text to the email.

<form method="post" action="mailto:emailaddress@co.uk.com">
  First name:<br>
  <input type="text" name="firstname" value="MR">
  <br>
  Last name:<br>
  <input type="text" name="lastname" value="Test">
  <br><br>
  <input type="submit" value="send email" />
</form> 

1
  • <html> <body> <form method="post" action="mailto:emailaddress@co.uk.com"> First name:<br> <input type="text" name="firstname" value="MR"> <br> Last name:<br> <input type="text" name="lastname" value="Test"> <br><br> <input type="submit" value="send email" /> </form> ​<!DOCTYPE html> <html> <body> – Dexterwolf Oct 24 '17 at 14:03
0
<input  type="text" name="firstname" id="fstName"/>
<input  type="text" name="lastname" id="lstName"/>

to get value of those textbox use this:

FirstName= $("#fstName").val();
LastName= $("#lstName").val();
6
  • Where do I put that bit of code though Thanks – Dexterwolf Oct 24 '17 at 14:33
  • I have added the id="fstName"/> part but where do I add the val( ); to the code. – Dexterwolf Oct 24 '17 at 14:56
  • It's a JQuey you can create a Submit function to get value and send it via Mail – Melad Batta Oct 24 '17 at 15:16
  • I have added the code but still it does not add the content when I select submit to the email. Below is the full code that I have. – Dexterwolf Oct 25 '17 at 7:09
  • <head> <script src="ajax.googleapis.com/ajax/libs/jquery/3.2.1/…> <script> FirstName= $("#fstName").val(); LastName= $("#lstName").val(); }); }); </script> </head> <body> <form method="post" action="mailto:email@co.uk"> First name:<br> <input type="text" name="firstname" id="fstName" /> <br> Last name:<br> <input type="text" name="lastname" id="lstName" /> <br><br> <strong> <input type="submit" value="Send Email" /></strong> </form> – Dexterwolf Oct 25 '17 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.