Forum Moderators: open
I've been asked to set up an online form for a side project at work, and unfortunately, I only have a very small understanding of javascript.
The form needs to send data directly to a specified email address rather than bring up an email box, which is what it's doing at the moment due to the mailto: command. Here's the HTML part of the form (I've had to take out my email address for privacy reasons):
<form name="omaform" action="mailto:email@address.com?subject="From the suggestion box">
Your Name: (optional)<br>
<input type="text" size="26" name="Name"><br><br>
Your Suggestion:<br>
<textarea name="Suggestion" rows="8" cols="20">
</textarea><br><br>
<input type="submit" value="Submit Suggestion">
</form>
Can anyone provide me with the .js code or anything else I'd need to have the data from the form sent directly to the email? It's meant to be for anonymous submissions so obviously having the email edit box pop up isn't any good!
The site this will be on is hosted on a Streamline server if that's any help!
<form name="x" method="POST" action="mailto:your_addy@..." enctype="text/plain">
...
</form>
I strongly suggest, however, that you use a server-side script using Perl, PHP, ASP, Java, etc that accepts the form and processes the email for you rather than exposing the address, giving direct access to a form with your email address (or your client's email!) and allowing chaos to ensue.
<form name="omaform" action="mailto:email@address.com?subject="From the suggestion box">
Notice that? You start to wrap the mailto: string in "double quotes", then open the subject string in "double quotes" as well. You need to do something like this instead:
<form name="omaform" action="mailto:email@address.com?subject='From the suggestion box'">
Don't forget to add the method and enctype attributes I mentioned!
If you need further assistance building a proper mail form that submits to a server-side script, please let us know.
But if someone uses an online mail service, such as Yahoo, Gmail, etc., this won't work. It will open the default mail client and most likely confuse the user.