...

View Full Version : How to tsfr data from a form to an email using javascript/html



ElizaKaye
11-12-2012, 07:12 AM
Thankyou. I need to tsfr data from a form using html/javascript with an email address, subject line and the rest of the data to go into the body of the email.

Philip M
11-12-2012, 07:20 AM
This is really depressing. I explained the problems and unsuitability of mailto: in

http://www.codingforums.com/showthread.php?t=281636 post#2.

Was that not clear in some way? Did you not understand "Modern browsers no longer accept mailto: as a form action - they simply open the email program (if any) and ignore the form."


"Let us be thankful for the fools. But for them the rest of us could not succeed. " - Mark Twain, US humorist, novelist, short story author, & wit (1835 - 1910)

minder
11-12-2012, 09:33 AM
Thankyou. I need to tsfr data from a form using html/javascript with an email address, subject line and the rest of the data to go into the body of the email.

This really should be done server side especially if the form data contains things like uploaded images or other type of data for attachments like pdf files.

Here is a very good and popular tutorial on how to send emails with or without attachments using PHP.

http://webcheatsheet.com/php/send_email_text_html_attachment.php

ElizaKaye
11-12-2012, 08:02 PM
Thank you - however I don't use PHP - YET.
The file I am working on only has javascript/html as requested in my heading.

Philip M
11-12-2012, 09:36 PM
Thank you - however I don't use PHP - YET.
The file I am working on only has javascript/html as requested in my heading.

In that case you cannot send the contents of your form with any reliability.

Logic Ali
11-12-2012, 10:00 PM
Thank you - however I don't use PHP - YET.
The file I am working on only has javascript/html as requested in my heading.
Most ISPs provide a free form to email script, which should be perfectly adequate provided that you don't need to perform any server-side validation, which obviously you don't.
Just search your ISPs website for the instructions on how to use it.

ElizaKaye
11-19-2012, 01:13 AM
HTML ONLY please. I HAVE THE DATA FROM THE FORM GOING TO AN EMAIL ADDRESS WITH THE DATA COMING THROUGH in the body of the email.

Now I need help TO GET THE SUBJECT LINE TO COME THROUGH (from a drop down box with the NAME interest) and how to format the data that is coming through please.

Philip M
11-19-2012, 07:30 AM
You don't give up do you? mailto: is obsolete - you should use PHP to transmit your form.

But to answer your question:-


<select id = "interest" onchange = "getVal()">
<option value = "0">Select your interest...</option>
<option value = "Drinking">Drinking</option>
<option value = "Gambling">Gambling</option>
<option value = "Womanising">Womanising</option>
</select>

<script type = "text/javascript">
function getVal() {
var val = document.getElementById("interest").value;
var emadd = "me@mydomain.com";
if (val !=0) {
emadd = emadd +"?subject=" + val;
alert (emadd);
}
}
</script>


You cannot format the form data in any way. And, for the third time, modern browsers no longer accept mailto: as a form action - they simply open the email program (if any) and ignore the form.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum