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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Location
    Canada
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form image submit button mailto not working

    I made an image submit button with rollovers in a form using Javascript. On the href of my submit-image I call a javascript function to submit the form.

    Once in the function I can't seem to make the mailto work.

    This should work and actually does work when I call the function on the onSubmit of the form instead of the href of the submit-image.
    Code:
    function doSubmit(form){
    form.action = 'mailto:myemail@email.com?subject=ItsNotWorking';
    }
    
    (...)
    
    <a href="javascript:doSubmit(TheForm)" onMouseOut  = "switchImage('submitImage',2)" onMouseOver = "switchImage('submitImage',3)" >
    <img name="submitImage" src="images/bt_submit.gif" width="67" height="18" border="0"></a>
    When I do this instead with the same function it works.
    Code:
    <FORM NAME="TheForm" ACTION="" METHOD="post" enctype="text/plain" onSubmit="return doSubmit(this)">
    I just don't understand why it's not working when I call the function from the image. Any ideas?

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,639
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Most browsers either ignore action=mailto or just open the email program and ignore the form. If you want to use mailto: then dump the form. If you want to use the form then dump the mailto and use a server side form2mail script.
    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
    •