Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-12-2012, 07:12 AM   PM User | #1
ElizaKaye
New Coder

 
Join Date: Nov 2012
Posts: 12
Thanks: 4
Thanked 0 Times in 0 Posts
ElizaKaye is an unknown quantity at this point
How to tsfr data from a form to an email using javascript/html

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.
ElizaKaye is offline   Reply With Quote
Old 11-12-2012, 07:20 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
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)
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is online now   Reply With Quote
Old 11-12-2012, 09:33 AM   PM User | #3
minder
Banned

 
Join Date: Oct 2012
Posts: 81
Thanks: 0
Thanked 4 Times in 4 Posts
minder can only hope to improve
Quote:
Originally Posted by ElizaKaye View Post
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_em...attachment.php
minder is offline   Reply With Quote
Old 11-12-2012, 08:02 PM   PM User | #4
ElizaKaye
New Coder

 
Join Date: Nov 2012
Posts: 12
Thanks: 4
Thanked 0 Times in 0 Posts
ElizaKaye is an unknown quantity at this point
Thank you - however I don't use PHP - YET.
The file I am working on only has javascript/html as requested in my heading.
ElizaKaye is offline   Reply With Quote
Old 11-12-2012, 09:36 PM   PM User | #5
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by ElizaKaye View Post
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.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is online now   Reply With Quote
Old 11-12-2012, 10:00 PM   PM User | #6
Logic Ali
Regular Coder

 
Logic Ali's Avatar
 
Join Date: Sep 2010
Location: London
Posts: 959
Thanks: 0
Thanked 198 Times in 193 Posts
Logic Ali will become famous soon enoughLogic Ali will become famous soon enough
Quote:
Originally Posted by ElizaKaye View Post
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.
Logic Ali is offline   Reply With Quote
Old 11-19-2012, 01:13 AM   PM User | #7
ElizaKaye
New Coder

 
Join Date: Nov 2012
Posts: 12
Thanks: 4
Thanked 0 Times in 0 Posts
ElizaKaye is an unknown quantity at this point
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.
ElizaKaye is offline   Reply With Quote
Old 11-19-2012, 07:30 AM   PM User | #8
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
You don't give up do you? mailto: is obsolete - you should use PHP to transmit your form.

But to answer your question:-

Code:
<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.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is online now   Reply With Quote
Users who have thanked Philip M for this post:
ElizaKaye (11-25-2012)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:52 PM.


Advertisement
Log in to turn off these ads.