[jQuery] Need help updating sorted records into db....

[jQuery] Need help updating sorted records into db....


Hi, all.
I'm trying to use the plug-in TableDnD to sort
records output via ColdFusion 8.
I've got the drag-n-drop working and can get the
sort_order variable as a list from a hidden field
when the form is submitted.
The sort_order variable is created using this code
from aliaspooryorik at
http://aliaspooryorik.wordpress.com/2008/02/27/sorting-table-rows-with-jquery-and-coldfusion/:
$(function(){
$("#sortable-tbl").tableDnD();
$('#frm-sort').submit(function(){
var sRowOrder = "";
$("#sortable-tbl tr").each(function(i,o){
if (sRowOrder.length) {
sRowOrder += "," + o.id;
} else {
sRowOrder = o.id;
}
});
$('#sort_order').val(sRowOrder);
});
});
The question is how do I match the comma-delimited sRowOrder list values
with each record id in the db for an update query?
Here's my update query. You can see in the where clause that I need to attach
the section_id of each record to each row somehow. The id of each row is already
taken by the id of each tr.
<cfloop list="#form.section_order#" index="i">
                                    
        <cfquery name="update_section_order" datasource="#dsn#">
                                
            update community
             set section_order = <cfqueryparam cfsqltype="cf_sql_tinyint"
value="#listgetat(form.section_order, i)#">
             where section_id = ???
                                            
        </cfquery>
                                        
    </cfloop>
And here's the HTML for the table:
    <table id="sortable-tbl">
                                
        <cfoutput query="get_sections">
                                
        <tr id="#get_sections.section_order#">
            <td>#get_sections.section_title#</td>
            <td>Update</td>
            <td>Delete</td>
        </tr>
        
        </cfoutput>
        
    </table>
I'm certain the answer is fairly simple, but it probably involves tweaking
not only the HTML/CFML, but also the JS, and that's where I'm a little lost.
Suggestions, anyone?
Thanks,
Rick



























































    • Topic Participants

    • rick