?
Solved

Mailto form and onSubmit function

Posted on 1998-07-15
5
Medium Priority
?
1,078 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 200 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 real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…
Suggested Courses

777 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