Since this seems to be a popular thread, here's a quick and dirty
example of how it can be done.

You will need to modify the Javascript function to handle fields like
select boxes and radio buttons, but the principle is what's important.

Spike

############################
Begin code
############################

<cfif isDefined('form.test1')>
        <cfwddx action="CFML2WDDX" input="#form#" output="wFields">
        <cffile action="write"
file="#expandPath('./')#/#dateformat(now(),'YYMMDD')##timeformat(now(),'
HHMMSS')#.xml" output="#wFields#">
<cfelseif isDefined('url.test1')>
        <cfwddx action="CFML2WDDX" input="#url#" output="wFields">
        <cffile action="write"
file="#expandPath('./')#/#dateformat(now(),'YYMMDD')##timeformat(now(),'
HHMMSS')#.xml" output="#wFields#">
</cfif>

<cfoutput>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
        <title>Auto save</title>
</head>
<script>

        function saveform(formname,url,imgid) {
                var frm = eval('document.'+formname);
                var str = url;
                var pipe = document.getElementById(imgid);
                for (i=0;i<frm.elements.length;i++) {
                        if(frm.elements[i].name.length > 0) {
                                str += frm.elements[i].name + '=' +
frm.elements[i].value + '&';
                        }
                }
                if (confirm('You have unsaved data in the form. \nWould
you like to save it before closing the window?')) {
                        pipe.setAttribute('src',str);
                        alert('Your data has been saved');
                }
        }

</script>

<body onUnload="saveform('myform','#cgi.script_name#?','imagepipe')">
<img src="" style="display:none;" id="imagepipe">
<form name="myform" action="#cgi.script_name#" method="post">
        <input type="text" name="test1" value="test"><br>
        <input type="text" name="test2" value="test2"><br>
        <input type="Submit" value="Save">
</form>


</body>
</html>
</cfoutput>

############################
End code
############################


Stephen Milligan
Team Macromedia - ColdFusion
Co-author 'Reality Macromedia ColdFusion MX: Intranets and Content
Management'
http://spikefu.blogspot.com

> -----Original Message-----
> From: Sridhar Pedamallu 
> [mailto:[EMAIL PROTECTED]] 
> Sent: 28 November 2002 11:00
> To: [EMAIL PROTECTED]
> Subject: RE: [ cf-dev ] Closing a window
> 
> 
> This code does same work. But there is a problem.
> 
> If there is any link on the page and users click it then also 
> he gets the same message.
> 
> <html>
> <head>
>       <title>Close Suppressor demo</title>
> </head>
> <body  onBeforeUnload="return 'This will terminate your 
> session, requiring you to Logon again to continue.';"> Hello
> 
> </body>
> </html>
> 
> -----Original Message-----
> From: Giles Roadnight [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, November 28, 2002 09:50
> To: [EMAIL PROTECTED]
> Subject: RE: [ cf-dev ] Closing a window
> 
> 
> http://www.pricklythistle.com/samples/natwest.htm
> 
> That should work for you.
> 
> -----Original Message-----
> From: Robertson-Ravo, Neil (RX) 
> [mailto:[EMAIL PROTECTED]] 
> Sent: 28 November 2002 09:36
> To: '[EMAIL PROTECTED]'
> Subject: RE: [ cf-dev ] Closing a window
> 
> true, but I have found that list to be quiet as of late?
> 
> -----Original Message-----
> From: Tom Smith [mailto:[EMAIL PROTECTED]]
> Sent: 28 November 2002 09:36
> To: [EMAIL PROTECTED]
> Subject: Re: [ cf-dev ] Closing a window
> 
> 
> I think he should share it with the list, you never know when 
> this sort of thing could come in handy....
> 
> and anyway, why don't you ask js-jive as well?  they might 
> offer better help on this javascript problem you are having.
> ----- Original Message -----
> From: "Robertson-Ravo, Neil (RX)" 
> <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Thursday, November 28, 2002 9:28 AM
> Subject: RE: [ cf-dev ] Closing a window
> 
> 
> > Hi Giles.
> >
> > I couldn't get this to work at all? the window just closes with not 
> > warning.... have you got an exampe you could send to me offlist?
> >
> >
> >
> > -----Original Message-----
> > From: Giles Roadnight [mailto:[EMAIL PROTECTED]]
> > Sent: 27 November 2002 19:26
> > To: [EMAIL PROTECTED]
> > Subject: RE: [ cf-dev ] Closing a window
> >
> >
> > Here is a cut down version of the natwest page:
> >
> > <html>
> > <head>
> > <title>Close Suppressor demo</title>
> > <SCRIPT LANGUAGE=javascript>
> > <!--
> > var suppressCloser=false;
> > function window_onbeforeunload() {
> > if (!suppressCloser)
> > event.returnValue="This will terminate your
> > session, requiring you to Logon again to continue."
> > }
> > //-->
> > </SCRIPT>
> > </head>
> > <body  onBeforeUnload="window_onbeforeunload()">
> > Hello
> > </body>
> > </html>
> >
> > this worked for me on IE 6.
> >
> > Hope that helps
> >
> > -----Original Message-----
> > From: Snake [mailto:[EMAIL PROTECTED]]
> > Sent: 27 November 2002 16:19
> > To: [EMAIL PROTECTED]
> > Subject: RE: [ cf-dev ] Closing a window
> >
> > Ok so redirect back to the page if the formfields are not fille din 
> > then.
> >
> > Onunload="location.href = 'mypage.cfm'"
> >
> >
> > -----Original Message-----
> > From: Robertson-Ravo, Neil (RX) 
> > [mailto:[EMAIL PROTECTED]]
> > Sent: 27 November 2002 16:12
> > To: '[EMAIL PROTECTED]'
> > Subject: RE: [ cf-dev ] Closing a window
> >
> >
> > yep, that displays the box, but it still closes the window....
> >
> > -----Original Message-----
> > From: Snake [mailto:[EMAIL PROTECTED]]
> > Sent: 27 November 2002 16:13
> > To: [EMAIL PROTECTED]
> > Subject: RE: [ cf-dev ] Closing a window
> >
> >
> > <body onunload="return confirm('are you sure')">
> >
> >
> > -----Original Message-----
> > From: Robertson-Ravo, Neil (RX) 
> > [mailto:[EMAIL PROTECTED]]
> > Sent: 27 November 2002 16:06
> > To: '[EMAIL PROTECTED]'
> > Subject: RE: [ cf-dev ] Closing a window
> > displays the
> >
> > nope, doesnt work :
> >
> > <html>
> > <head>
> > <title>Untitled</title>
> >
> >
> > </head>
> >
> > <body onbeforeunload="window.event.returnValue ="Are you sure you
> wanna
> > just close this?">
> >
> >
> > </body>
> > </html>
> >
> > -----Original Message-----
> > From: Matt Horn [mailto:[EMAIL PROTECTED]]
> > Sent: 27 November 2002 16:04
> > To: [EMAIL PROTECTED]
> > Subject: Re: [ cf-dev ] Closing a window
> >
> >
> >
> > onbeforeunload="
> > window.event.returnValue ="Are you sure you wanna just close this?"
> >
> > try that
> >
> >
> >
> > At 15:56 27/11/2002, you wrote:
> > >I'll try and find out how they do it when I get home tonight then.
> > >
> > >----- Original Message -----
> > >From: "Robertson-Ravo, Neil (RX)" 
> > ><[EMAIL PROTECTED]>
> > >To: <[EMAIL PROTECTED]>
> > >Sent: Wednesday, November 27, 2002 3:45 PM
> > >Subject: RE: [ cf-dev ] Closing a window
> > >
> > >
> > > > I am at Windows update, and I cannot see this behaviour.
> > > >
> > > > -----Original Message-----
> > > > From: Giles Roadnight [mailto:[EMAIL PROTECTED]]
> > > > Sent: 27 November 2002 15:45
> > > > To: [EMAIL PROTECTED]
> > > > Subject: Re: [ cf-dev ] Closing a window
> > > >
> > > >
> > > > Well, I know for a fact that when I try to close my 
> natwest online 
> > > > bankc window it asks me if I want to navigate away from 
> the page.
> if
> >
> > > > I click cancel it does not close. Sma on windows update.
> > > > ----- Original Message -----
> > > > From: "Robertson-Ravo, Neil (RX)" 
> > > > <[EMAIL PROTECTED]>
> > > > To: <[EMAIL PROTECTED]>
> > > > Sent: Wednesday, November 27, 2002 3:40 PM
> > > > Subject: RE: [ cf-dev ] Closing a window
> > > >
> > > >
> > > > > yep, thought so, I can get it to trigger an event, but the
> browser
> > still
> > > > > just closes...arse
> > > > >
> > > > > -----Original Message-----
> > > > > From: Rich Wild [mailto:[EMAIL PROTECTED]]
> > > > > Sent: 27 November 2002 15:40
> > > > > To: '[EMAIL PROTECTED]'
> > > > > Subject: RE: [ cf-dev ] Closing a window
> > > > >
> > > > >
> > > > > no definite way. You can't prevent users from killing the
> browser
> > > > > or
> > > > turning
> > > > > off the client machine etc.
> > > > >
> > > > >
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Robertson-Ravo, Neil (RX) 
> > > > > > [mailto:[EMAIL PROTECTED]]
> > > > > > Sent: 27 November 2002 15:38
> > > > > > To: '[EMAIL PROTECTED]'
> > > > > > Subject: [ cf-dev ] Closing a window
> > > > > >
> > > > > >
> > > > > > Is there anyway to prevent a user from closing a 
> popup/browser 
> > > > > > window before they have saved their form values?  
> i.e. if the 
> > > > > > form values are not blank, do not close.
> > > > > >
> > > > > > Neil
> > > > > >
> > > > > > --
> > > > > > ** Archive:
> > http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> > > > > >
> > > > > > To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> > > > > > For additional commands, e-mail: 
> > > > > > [EMAIL PROTECTED] For human help, e-mail: 
> > > > > > [EMAIL PROTECTED]
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > ** Archive: 
> > > > > http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> > > > >
> > > > > To unsubscribe, e-mail: 
> [EMAIL PROTECTED]
> > > > > For additional commands, e-mail:
> [EMAIL PROTECTED]
> > > > > For human help, e-mail: [EMAIL PROTECTED]
> > > > >
> > > > > --
> > > > > ** Archive: 
> > > > > http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> > > > >
> > > > > To unsubscribe, e-mail: 
> [EMAIL PROTECTED]
> > > > > For additional commands, e-mail:
> [EMAIL PROTECTED]
> > > > > For human help, e-mail: [EMAIL PROTECTED]
> > > > >
> > > >
> > > >
> > > > --
> > > > ** Archive: 
> > > > http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> > > >
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: 
> [EMAIL PROTECTED] 
> > > > For human help, e-mail: [EMAIL PROTECTED]
> > > >
> > > > --
> > > > ** Archive: 
> > > > http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> > > >
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: 
> [EMAIL PROTECTED] 
> > > > For human help, e-mail: [EMAIL PROTECTED]
> > > >
> > >
> > >
> > >--
> > >** Archive:
> http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> > >
> > >To unsubscribe, e-mail: [EMAIL PROTECTED]
> > >For additional commands, e-mail: 
> [EMAIL PROTECTED] For 
> > >human help, e-mail: [EMAIL PROTECTED]
> >
> >
> > --
> > ** Archive: 
> http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> >
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: 
> [EMAIL PROTECTED] For 
> > human help, e-mail: [EMAIL PROTECTED]
> >
> > --
> > ** Archive: 
> http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> >
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: 
> [EMAIL PROTECTED] For 
> > human help, e-mail: [EMAIL PROTECTED]
> >
> >
> > --
> > ** Archive: 
> http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> >
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: 
> [EMAIL PROTECTED] For 
> > human help, e-mail: [EMAIL PROTECTED]
> >
> > --
> > ** Archive: 
> http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> >
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: 
> [EMAIL PROTECTED] For 
> > human help, e-mail: [EMAIL PROTECTED]
> >
> >
> > --
> > ** Archive: 
> http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> >
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: 
> [EMAIL PROTECTED] For 
> > human help, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> > --
> > ** Archive: 
> http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> >
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: 
> [EMAIL PROTECTED] For 
> > human help, e-mail: [EMAIL PROTECTED]
> >
> > --
> > ** Archive: 
> http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> >
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: 
> [EMAIL PROTECTED] For 
> > human help, e-mail: [EMAIL PROTECTED]
> 
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts http://uk.my.yahoo.com
> 
> -- 
> ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: 
> [EMAIL PROTECTED] For human help, e-mail: 
> [EMAIL PROTECTED]
> 
> -- 
> ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: 
> [EMAIL PROTECTED] For human help, e-mail: 
> [EMAIL PROTECTED]
> 
> 
> 
> -- 
> ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: 
> [EMAIL PROTECTED] For human help, e-mail: 
> [EMAIL PROTECTED]
> 
> -- 
> ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: 
> [EMAIL PROTECTED] For human help, e-mail: 
> [EMAIL PROTECTED]
> 
> 
> 


-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to