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

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create Web Applications With ColdFusion MX7 & Flex 2. 
Build powerful, scalable RIAs. Free Trial
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJS 

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:273582
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