Su,
I second Nick's last comment as that's how I generally do it so that the
user can come back and finish without starting all over. It really depends
on how big your form is and how long it takes the user to fill it out. If
you have 20 minute sessions, and the user really has to think about some of
the information, or gather documents before they can fill it out, etc., you
don't want them losing what they have already entered.
And to answer your other question, yes, you save to the session scope on the
server side. Although you could use AJAX to save values to a session
variable onChange of each field (I've done this before too), it's a bit more
complicated. Doing this is highly intuitive as they can switch back and
forth from tab to tab easily and not lose any information, even if they
haven't submitted the pages themselves. Pretty slick, but like I said, a
bit complicated.
If you want to go the ajax route, install ajaxCFC (google - by Rob Gonda)
and then create a CFC that looks like this:
<cfcomponent name="ajaxfunctions" extends"ajax">
<cffunction name="saveSessionVar">
<cfargument name="varname">
<cfargument name="varvalue">
<cfset setVariable("session." & arguments.varname,arguments.varvalue) >
<cfreturn "sometext"> <!--- ajaxCFC requires that your function return
SOMETHING --->
</cffunction>
</cfcomponent>
Call this CFC ajaxfunctions.cfc and place it in your ajax folder where the
ajax.cfc file is located.
Then, on your HTML page where your forms are, put the following lines in
your <head> (you can change the paths to suit your application, of course):
<script language="javascript">
var _ajaxConfig =
{'_cfscriptLocation':'/ajax/ajaxfunctions.cfc','_jsscriptFolder':'/ajax'};
</script>
<script type="text/javascript" src="/wernervas/js/ajax/ajax.js"></script>
Then, on your form fields, you would add an
onChange="setSessionVar('fielanme',this.value);" to each field.
Then, you need two javascript functions that look like this:
function setSessionVar(sVarName,sValue) {
DWREngine._execute(_ajaxConfig._cfscriptlocation, null,
"saveSessionVar", sVarName, sValue, dummyCallback);
}
function dummyCallback(sText) {
// do nothing here.
}
Implement all that, and your session variables will be saved every time a
user tabs or clicks out of a field in which they have changed the value.
You might need to tweak it some, but this allows you to save their data to
the session scope without submitting the page.
Dave
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j
Archive:
http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:3984
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15