Rick,
Hang tight. I'm off to lunch. I'll answer when I get back. :o)
Chris
Rick Faircloth wrote:
> Thanks for the code, Chris...
>
> I've looked it over (and certainly wouldn't pretend to understand it all),
> but I did notice that it sends a user to "Thank You" page if all is well.
>
> In my case, however, what I've got is a mortgage calculation form
> which performs these processes (at least this is what I'm trying to get to):
>
> - validate input on a "per field" basis (got that worked out) using CF code
> for validation
> - "Calculate" button for submission is disabled until all fields have
> validated
> - once all fields validate, CF processes the data and returns the mortgage
> payment
> to the form page
>
> I'm stuck after achieving the first part. I can validate all fields
> individually, server-side,
> using this code:
>
> $(document).ready(function(){
> $("input:text").debug().each(function(){
>
> var a = new Array();
>
> $(this).blur(function(){
>
> var Params={};
> Params[this.name]=this.value;
>
> console.log(Params);
>
>
> $.post("Calc_Test_Process_Field.cfm",Params);
>
> });
> });
> });
>
> After this has done its work, I want the Calculate button enabled,
> then, once the Calculate button is clicked, all form fields are
> submitted, CF processes the data and runs the formula, and the
> result is returned via Ajax to the form page for display.
>
> What I'm lacking is the last part... getting the calculated result
> (which I have) passed back to the form page.
>
> I tried using this with "onSubmit" and "onClick" but that wasn't making
> any difference:
>
>
> function CalculateMortgage(){
>
> var Params = {};
>
> $("input:text").each(function(){
>
> var Params={};
> Params[$(this).attr("name")] = $(this).val();
> });
>
> console.log(Params);
>
> $.post("Calc_Test_Process_Field.cfm", Params, function(data){
>
> $("#Result").empty().append(data);
>
> });
>
> return false;
> };
>
>
> How would (if needed) would your code be modified to handle
> this situation?
>
> One last thing for now... I noticed a JSON reference in your code...
> I thought I couldn't use JSON with CF 4.5???
>
> Rick
>
>
>
>
>
>
>
> -----Original Message-----
> From: Christopher Jordan [mailto:[EMAIL PROTECTED]
> Sent: Friday, March 23, 2007 1:20 PM
> To: CF-Talk
> Subject: Re: Scorpio - What to do until then?
>
> Rick,
>
> Rick Faircloth wrote:
>
>> But the problem I've come up against is, once the entire
>> form has valid entries, how to post the entire form
>> and have the result returned via Ajax.
>
> So, by post the form, you just mean that once all has been validated,
> that you need the Form fields (all inputs -- hidden, radio, textarea,
> select, etc.) to be passed to the server via Ajax right?
>
> Have you tried something like this:
>
> <script>
> function CreateDataObject(){
> var obj = new Object;
> // all inputs of type text, hidden, select and textarea
> $("input:text,input:hidden,select,textarea").each(function(){
> obj[this.name] = this.value;
> //eval("obj." + this.name + " = '" + this.value + "';");
> });
> //dump(obj,false);
> return obj
> }
>
> var HasBeenSubmitted = false;
> function SaveApplication(){
> if(!HasBeenSubmitted){
> // first validate the form
> if(ValidateForm(true)){
> HasBeenSubmitted = true;
> var myStruct = CreateDataObject();
> //dump(myStruct);
> var parms = "ApplicationData=" + $.toJSON(myStruct);
> $.ajax({
> type: "POST",
> url: "ProcessEmploymentApp.cfm",
> datatype: "html",
> data: parms,
> success: function(data){
> location.href="thankyou.cfm";
> },
> error: function(data){
> alert("There was a problem submitting/");
> }
> });
> }
> }
> else{
> alert("can't submit more than once.");
> return;
> }
> }
> <script>
>
> The CreateDataObject (a lousy name for it probably), creates what you
> can think of as a struct which contains name/value pairs which I then
> pass to the handling CFM page via ajax.
>
> Have you tried a method like this? I've mentioned this code to someone
> on the jQuery list once (it may have been you). Daemach and I were
> tag-team helping someone and this was my proposed solution. This is code
> that I'm actually using in a production environment.
>
> Does this help? Let me know if any of it doesn't make sense.
>
> Cheers,
> Chris
>
--
http://www.cjordan.us
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 by AdobeĀ®
Dyncamically transform webcontent into Adobe PDF with new ColdFusion MX7.
Free Trial. http://www.adobe.com/products/coldfusion?sdid=RVJV
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:273608
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4