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 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer A Javascript for sending emails by using a form on a webpage?

    Sorry if it's a complicated question. I need help with this so I turned here; I'm sorry if I'm doing something wrong.

    What I'm trying to say is that, is there a script that makes a form box on a webpage with default words inside of it, and once the user types the things out, a link is pressed and what was in the form is sent as an email?

    It's sort of like an application kind of thing, where the default words are questions in my case.

    I've tried googling but no success.

    Thanks in advance,
    Moogle ^_^

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You can set the values of the boxes with html but to actually get the information to be sent you will need a server side language, javascript is clientside and cannot do this.

  • #3
    Banned
    Join Date
    Oct 2005
    Location
    I'm in GMT -5
    Posts
    314
    Thanks
    0
    Thanked 1 Time in 1 Post
    moogle:

    If you are unable or unwilling to use server side language, the following will work in IE only.

    Code:
    <html>
    <head>
    <script type="text/javascript">
    
    	function sendMail(isForm){
    
    		isBody = "";
    		recipient = "me@someDomain.com";
    		isSubject = "Form Data";
    		isBody = "Name: " + isForm.personal.value +"%0D%0A";
    		isBody += "Address: " + isForm.address.value +"%0D%0A";
    		isBody += "City: " + isForm.city.value +"%0D%0A";
    		isBody += "State: " + isForm.state.value +"%0D%0A";
    		isBody += "Zip: " + isForm.zip.value;
    		document.forms.Send.action = "mailto:"+recipient+"?subject="+isSubject+"&body="+isBody+"&nbsp";
    	}
    
    </script>
    </head>
    <body>
    <form name='Form1'>
    Name <input type='text' name='personal' value="John Doe" size=25><br>
    Address <input type='text' name='address' value="123 Main Street" size=30><br>
    City <input type='text' name='city' value="Springfield" size=15> State <input type='text' name='state' value="OH" size=2><br>
    Zip Code <input type='text' name='zip' value="12345" size=4><br>
    </form>
    <form name='Send' action=''>
    <input type="submit" value="Send by Email" onclick="sendMail(document.Form1)">
    </form>
    </body>
    </html>

  • #4
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you very much ^_^ That's just what I needed.

    Happy holidays

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,590
    Thanks
    0
    Thanked 644 Times in 634 Posts
    That code will only work if there is a separate email program available on the computer (which rules out internet cafes and may other users). Also it doesn't work on modern browsers. Also it gives your email address to the spammers. 99% of the emails resulting from the code will be spam.

    Use a server side solution. If you don't have access to put a script on your own site then use a third party one from somewhwere like Bravenet.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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