Solved

Mailto form and onSubmit function

Posted on 1998-07-15
5
1,049 Views
Last Modified: 2006-11-17
Can someone please tell me how to get a mailto form to access another html page once a user presses the "Submit" button?  I am having trouble with the onSubmit event.  Here is what I have:

<INPUT TYPE=SUBMIT VALUE="SUBMIT" onSubmit="takeOff()">

I can't get the function written correctly (obviously since I cannot get it to work).  I have tried location.href, but not sure if the syntax is correct.  Any suggestions?
0
Comment
Question by:kmbac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
jbirk earned 50 total points
ID: 1266603
OK, first, the onSubmit() command must be in the <FORM> tag, not an input tag.  But when using a mailto, changing the href after a submission doesn't work very well (or as easily as would be expected

just using the statement location='' or location.href='' in the onSubmit() event doesn't work, and it won't on the onClick event of the submit button either...  And since you can't use form.submit() from a javascript function when the form is a mailto action, using a normal button won't work either.

Instead this will work, but it always goes to the next page even if the form was not correctly submitted (like if they refuse to send it because with a mailto action it always asks if you want to submit it). Anyway here it is:

<INPUT TYPE="submit" VALUE="Submit" onClick="setTimeout('changehref()',2000);">
and then in the header section:
<SCRIPT language="JavaScript">
<!-- hide
function changehref()
{location="next.html";
}
// -->
</SCRIPT>

hope this helped,
Josh
0
 

Author Comment

by:kmbac
ID: 1266604
Thanks for the explanation. ;)  It works just fine.
0
 

Author Comment

by:kmbac
ID: 1266605
To add, if I would have used the onClick event, it would have worked also.  I tried the following:

function takeOff()
   {location="thanks.html";
   }
Unfortunately, I thought I needed to use the onSubmit event.  

Thanks a lot,
Karsten
0
 
LVL 8

Expert Comment

by:jbirk
ID: 1266606
If I answered the question to your liking and you need no further assistence, could please grade my answer so the question gets sent to the PAQ?
Thanks,
Josh
0
 

Author Comment

by:kmbac
ID: 1266607
Thanks again.  Sorry for the delay.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question