Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Nov 2012
    Posts
    12
    Thanks
    4
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,919
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    This is really depressing. I explained the problems and unsuitability of mailto: in

    Trying to compare value of option input box and if age under 18 "error message" 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.

  • #3
    Banned
    Join Date
    Oct 2012
    Posts
    81
    Thanks
    0
    Thanked 4 Times in 4 Posts
    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

  • #4
    New Coder
    Join Date
    Nov 2012
    Posts
    12
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thank you - however I don't use PHP - YET.
    The file I am working on only has javascript/html as requested in my heading.

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,919
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    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.

  • #6
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    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.

  • #7
    New Coder
    Join Date
    Nov 2012
    Posts
    12
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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.

  • #8
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,919
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    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.

  • Users who have thanked Philip M for this post:

    ElizaKaye (11-25-2012)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •