erik tom wrote:
> Tell me how. I am calling the function like this <input id="moveUP" 
> name="moveUp" onclick="moveUp(-1)"> and the same for movedown . And it works 
> my question is how can i update the database 
>   
With your "moveUp(-1)" call, are you passing just a -1 or are you also 
passing whatever unique DB identifier of the item you're trying to move 
up? If not, you're going to need to do that, at the very least. Or, pass 
in the unique IDs of the two items affected - i.e.

move(#currentItemID#, #previous or next itemID#) (previous if you're 
doing a move up, next if you're doing a move down)

That way you know which two items to switch. Pass those values on to 
your next script, where you do the DB calls to switch the vals - you get 
the order-by values for the two IDs, and then update both records with 
each other's order-by values.

<cfquery name="getOrderBy">
    SELECT ID, OrderBy
    FROM yourTable
    WHERE ID IN (#firstIDpassed#, #secondIDpassed#)
</cfquery>

<cfquery>
    UPDATE yourTable
    SET   OrderBy = #getOrderBy.OrderBy[2]#
    WHERE   ID = #getOrderBy.ID[1]#
</cfquery>

<cfquery>
    UPDATE yourTable
    SET   OrderBy = #getOrderBy.OrderBy[1]#
    WHERE   ID = #getOrderBy.ID[2]#
</cfquery>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade to ColdFusion 8 and integrate with Adobe Flex
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

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