...

View Full Version : Sending Email upon exiting a form



KingB24
02-16-2003, 01:33 AM
My client wants to be able to email customers when they exit a form, asking them why they didn't complete it. Is this even possible in ASP? Can I use the session_onend function in the global.asa file to do this?

Leeus
02-16-2003, 09:50 AM
You could use Javascript to open a page that fires off an email when they close that window, how would you get their address though?

whammy
02-16-2003, 04:25 PM
Nick? :D

KingB24
02-17-2003, 12:15 AM
I have their email address after they complete the first page of the form. I want to be able to shoot that person an email if they close their browser after the first page of the form. The form has four pages. How would I use javascript then? Use OnBeforeUnload in the body tag to call another asp page using javascript, that would generate the email? What would that code look like then in the body tag? This is Nick, Rob.

whammy
02-17-2003, 12:57 AM
Ok... I got this to work... however, I still don't know how to tell whether they clicked "cancel" or "ok", since you have to return that stupid string to OnBeforeUnload.

I'm thinking maybe stick their "UserID" (you know what I mean) in the url and throw it in a database... then have some DTS package or some script that runs and emails everyone (by distinct email address) in the database that hasn't finished the form, and is older than, say, 20 minutes? We'd have to do some testing on that, but it might work... of course changing some bit field in the database when the script or whatever executes so they don't get emailed again.

If you generated an email every time this function was called, it would tick some people off... ;)



<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title>UnUnloadTest</title>
<script type="text/javascript">
<!--
function changeImage() {
t = new Date()
time = t.getTime();
document.images['myimage'].src = "http://rob/birthdate.asp?blah=" + t;
return "I don't like proprietary technology on websites!";
}
// -->
</script>
</head>
<body onBeforeUnload="return changeImage()">
<div>
<img src="w3c_xhtml.gif" id="myimage" width="1" height="1" alt="" />
</div>
</body>
</html>

whammy
02-17-2003, 01:13 AM
This all comes back to doing it with a database, for every possible scenario I can imagine, since they could fire the onBeforeUnload event a couple of times, perhaps, and then complete the form. Even if we got the global.asa idea working, it might not be as easy as this idea, though...:

Send an email the VERY first time the onBeforeUnload event is triggered, and then have your ASP script check to see if you've already emailed them, so you don't send another email. Of course if it's done that way, you'd better have a nice apology in the original email like:

"If you completed the form after all, please disregard this email, and accept our sincerest apologies for making you mad at us twice."

Probably the easiest solution, anyway... they might go for that with the right wording. Of course they'd need to put in another disclaimer as well, stating "you will not receive any further email from *** unless you have opted to receive etc. etc. etc. blah blah blah"... otherwise they will add another set of angry (potential?) customers in addition to the ones they already have.

Of course, this may be a very good thing, since from my experience most of the angry customers they have were angry about the number and type of questions they had to answer for the ***********. So if they change their forms using this kind of feedback, it might be better in the long run.

I'll tell you more about it tomorrow, hehe.

:rolleyes:

P.S. For anyone wondering if I'm psychic, yeah... I am. LOL



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum