If you are looking to not refresh the page at all, then yes, ajax of some 
sort is the way to go.  There is nothing wrong with your approach, unless of 
course the user does not have JS enabled.

A non-ajax approach is to post to the same page that your form is on, and 
include your form processing only if the form submit button was pressed 
(<cfif structKeyExists(form,"mysubmitbutton")>).  Then you could do a "get" 
query after the form information has been saved in the db, and populate the 
form fields with the results of the "get" query.

This will refresh the page, but the fields will look the same to the user as 
when the form was originally submitted, and it's not JS-dependent.

-- Josh


----- Original Message ----- 
From: "Andrew McDuff" <[EMAIL PROTECTED]>
To: "CF-Talk" <[email protected]>
Sent: Tuesday, January 30, 2007 3:03 PM
Subject: Processing Forms without screen refresh using AjaxCFC


> Hi all,
>
> I'm seeking ideas / opinions on the following problem: I want to have 
> form, a "Save" and "Cancel" button. When clicking on "Save", it reads the 
> form contents and updates the database. The standard way to do this is to 
> do your CFFORM and call another CFM file where (action="blabla.cfm") which 
> reads the form variables, updates the database and then do a CFLOCATION 
> back to the main application. Of course, the CFLOCATION means re-loading 
> the whole app and re-initiating your CFC's, etc..etc..
>
> Now I'm into Ajax and using AjaxCFC and think have found a solution to 
> avoid the page refresh which is what I'm trying to achieve. I'm also 
> comfortable with JS and DOM manipulation, etc...Basically, I keep the 
> CFFORM structure within the HTML, replace the "Save" button to be "button" 
> type (and not "submit") with an 'onclick' to a new JS function. Within the 
> newly-created JS function (called from 'onclick'), I use a combination of 
> getElementbyId's (that is, I place ID's on the fields) to read the 
> contents of the fields and place them in an array. Finally, I make an Ajax 
> call passing the array and then, finally, in the CFC do the work of 
> updating the database.  Then in the JS callback function, the idea is to 
> display a message to the user a simple message "Updated" (positioned with 
> CSS, etc.)
>
> I don't know if that all makes sense to any of you folks out there. My 
> basic question is: am I over-engineering here and / or is there another 
> approach / easier way in order to avoid screen-refreshing when processing 
> forms?
>
> Thanks, Andy
>
> Madrid, Spain
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7 
Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs 
http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:268151
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to