Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document.form.submit to email automatically 1

Status
Not open for further replies.

marcow

Technical User
Mar 10, 2004
4
NL
When the submit button is pressed on a
<form method=&quot;post&quot; action=&quot;mailto:adress@adress.com&quot;>
form, it automatically sends out an email from the users email client.

Now I want to do the same with a confirm box.

confirm (&quot;bla bla bla&quot;)
document.formname.submit ()

But this only opens a new email and visitor still has to press send. How do I get it to send it out automatically as with the submitbutton of the form (as above)?

PS No I am not trying to spam people with this. They get a confirm popup after filling out info and then they also get their browsers insecure warning.
 
document.formname.submit() should do the exact same thing a submit button does. adam@aauser.com
 
Somehow there is a difference.
This one opens an new email message without sending it:
<html>
<head>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function autosubmit() {
document.form1.submit ()
}
onload=autosubmit;
</SCRIPT>
</head>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;mailto:address@you.com&quot; >
</form>
</body>
</html>

And this one sends it when pressing the submit.

<html>
<head>
</head>
<body>

<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;mailto:adress@you.com&quot; >
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
</form>
</body>
</html>
 
Hi Marcow,

The Reason you get the new email message without sending it is because you didn't have anything in the form to send, to solve this problem, simply add a hidden filed, for example:

<html>
<head>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function autosubmit() {
document.form1.submit ()
}
onload=autosubmit;
</SCRIPT>
</head>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;mailto:address@you.com&quot;>
<input type=&quot;hidden&quot; name=&quot;nothing&quot; value=&quot;&quot;>
</form>
</body>
</html>

This should give you the same result as you press the submit button..

hope this helps, Chiu Chan
cchan@gefmus.com
 
put the onload=autosubmit inside your body tags:

<body onload=&quot;autosubmit();&quot;> ray
rheindl@bju.edu

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top