It's working perfect Charlie, thanks.  One small change I made on the second line of the function:

Changed: var stForm = f;

Changed To: var stForm = Duplicate(f);

I wanted to leave the original #form# intact for further processing.  On testing the code I found that leaving out the Duplicate() function did not break the reference.

>Morgan:
>
>This seems to do it:
>
><html>
><head>
> <title></title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
>
> <cfscript>
>  function sortForm(f) {
>   var sortArray = arrayNew(2);
>   var stForm = f;
>   
>   var keys = structKeyArray(stForm);
>   var sortedKeys = "";
>   
>   for (i=1; i LTE #arrayLen(keys)#; i=i+1) {
>    if (NOT isNumeric(stForm[keys[i]])) {
>     structDelete(stForm, keys[i]);
>    }
>   }
>
>   sortedKeys = structSort(stForm, 'numeric');
>   
>   for (i=1; i LTE #arrayLen(sortedKeys)#; i=i+1) {
>    sortArray[arrayLen(sortArray)+1][1] = sortedKeys[i];
>    sortArray[arrayLen(sortArray)][2] = stForm[sortedKeys[i]];
>   }
>   return sortArray;
>  }
> </cfscript>
></head>
>
><body>
>
><cfparam name="form.field1" default="foo">
><cfparam name="form.field2" default="bar">
><cfparam name="form.field3" default="12">
><cfparam name="form.field4" default="foobar">
><cfparam name="form.field5" default="4">
><cfparam name="form.field6" default="barfoo">
><cfparam name="form.field7" default="8">
>
><cfdump var="#form#" label="this is the original form">
>
><cfset formSorted = sortForm(form)>
><cfdump var="#formSorted#" label="this should be sorted">
>
></body>
></html>
>
>let me know if that works out.
>
>Charlie
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to