Solved

Mailto form and onSubmit function

Posted on 1998-07-15
5
993 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
  • 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now