Solved

Mailto form and onSubmit function

Posted on 1998-07-15
5
1,036 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

820 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