[thelist] [thelist]Can you submit to two different pages from a form?

Chris Blessing webguy at mail.rit.edu
Fri Jul 26 15:33:01 CDT 2002


Janet-

You can't have JavaScript compose a CDONTS email because there's a
disconnect between the client side (the JavaScript executed by the browser)
and the server side (sending the email).

What you could do is use the onSubmit() method to allow the form to be
submitted directly to the Vertical Response site, and have it open a new
window with the details of the form in the querystring.  Use a variable to
determine if it's actually necessary to send the email...

Something like (wrap alert!):

function sendForm(frm, sendIt){
	if(sendIt){
		with(frm){
			var name = escape(frm.name.value);
			var email = escape(frm.email.value);

			var qs = "?name=" + name + "&email=" + email;
			var sendMail = window.open("/path/to/researchEmailScript.asp" +
qs,"theName");
		}
	}
}

In your <FORM...> tag:

<FORM onSubmit="sendForm(this.form, <% = booleanToSendEmail %>);" ...>

booleanToSendEmail is an ASP (or otherwise server-side) variable that you
will have to set based on whether the person is going to submit info to the
research center or not.

This would mimic a second form while allowing the first form (the real form)
to submit itself, submitting the info for the second form via the GET method
in a new window.  The "researchEmailScript.asp" page would do the email
sending itself, and once that was done it could write out a
<SCRIPT>window.close();</SCRIPT> line, closing the now-extraneous window.

The only thing you'd have to worry about would be someone closing the extra
window.

Anyhow, that's one way to do it.  HTH!

Chris Blessing
webguy at mail.rit.edu
http://www.330i.net




More information about the thelist mailing list