Solved

Mailto form and onSubmit function

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

724 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