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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    form mailto entry on selection list

    I have created this form. I would like to use javascript to mail the form to the selected email from the selection list when the submit button is pressed.
    could anyone help with this?

    <form name="Contact Us" id="contact" action="mailto:" method="post">
    <fieldset id="selection">
    Who would you like to email:
    <select>

    <option value="email1" >email1</option>
    <option value="email2" >email2</option>
    <option value="email3">email3</option>
    </select>
    <fieldset id="Name" >
    Name
    <input type="text" id="firstname" name="firstname">
    E-mail
    <input type="text" id="email" name="email">
    </fieldset>
    <fieldset id="question">
    Comments and Questions
    <input type="text" id="comment" name="comment" style="width: 500; height: 300">
    </fieldset>
    </form>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,015
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    The trouble with using this method (mailto) to send form results is its unpredictability. The method it is highly dependent on the browser in use and the email client in use (some people have only Yahoo or Hotmail). In particular, your visitor must have Internet Explorer as the browser and Outlook Express as the default client for this to work correctly. Even if your visitor is using Internet Explorer, but the default mail client is different (e.g Eudora) , your mailto form will not work. With all of the browser troubles, you're likely to lose about half of your users' messages. Most of the email clients that can successfully send a mail will prompt the user by a security dialog prior to sending - this can scare many users from continuing. Also, what about people with Javascript disabled?

    In fact few browsers these days accept mailto: as a form action. You need a really old browser for it to work as more modern browsers simply open the email program (if any) and ignore the form. If you are going to use a form then use a server-side formmail script as the action - there are several good free ones out there.

    For a simple PHP form feedback script see:- http://www.thesitewizard.com/archive/feedbackphp.shtml

  • #3
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this is for a class project so i am not intending to publish it like that

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,015
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    Ah, homework.

    Code:
    <form name="Contact_Us" id="contact" method="post" enctype="text/plain" onsubmit = "getEml()">
    <fieldset id="selection">
    Who would you like to email:
    <select name = "sel">
    <option value="email1">email1</option>
    <option value="email2" >email2</option>
    <option value="email3">email3</option>
    </select>
    <fieldset id="NameAndEmail" >
    Name
    <input type="text" id="firstname" name="firstname">
    E-mail
    <input type="text" id="email" name="email">
    </fieldset>
    <fieldset id="question">
    Comments and Questions
    <input type="text" id="comment" name="comment" style="width: 500; height: 300">
    </fieldset>
    <input type = "submit" value = "Submit the form">
    </form> 
    
    <script type = "text/javascript">
    function getEml() {
    var emailaddress = document.Contact_Us.sel.value;  
    window.location = "mailto:" + emailaddress; 
    }
    
    </script>
    Last edited by Philip M; 12-08-2009 at 08:16 AM.

  • #5
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    wow, i knew it had to be a simple code.
    thanks alot.


  •  

    Posting Permissions

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