I have the drop down of requirements which are based upon program ID (another drop down). Also I have 2 buttons Up and Down. Once I click on the button Up I get the reuirement move 1 step up and so on, now I need to update the database to update the sorder order of the reuirements based on the program selected
I wrote some CF code but it does not seems to be working
[CODE=cfm]<cfset oldorderlist = ValueList(infoN ote.reqid)>
<!--get current position -->
<cfset getcurrentposit ion =ListFindNoCase (oldorderlist,u rl.reqid)>
<!--remove the requirement from the list -->
<cfset oldorderlist =ListDeleteAt(o ldorderlist, getcurrentposit ion)>
<!--the lenght of the lsit -->
<cfset thelsitlen= ListLen(oldorde rlist)>
<cfoutput>#thel sitlen#</cfoutput>
<!--moving the position of the requirement-->
<cfif url.move EQ "moveUp">
<cfset newposition = getcurrentposit ion - 1>
<cfif newposition LT 1>
<cfset newposition = 1>
</cfif>
<cfelse>
<cfset newposition = getcurrentposit ion + 1>
<cfif newposition GT ListLen(oldorde rlist)>
<cfset newposition = thelistlen + 1>
</cfif>
</cfif>
<! add to list >
<cfif newposition GT thelistlen>
<cfset neworderlist = ListAppend(oldo rderlist, url.bookid)>
<cfelse>
<cfset neworderlist = ListInsertAt(ol dorderlist, newposition, url.reqid)>
</cfif>
<!-- loop through the list and update the database-->
<cfset counter = 1>
<cfloop index="i" list="#neworder list#">
<cfquery datasource="Hot Banana_Manager" >
UPDATE trnAcademicProg ramsAndRequirem entsMapping
SET sortorder = <cfqueryparam value="#counter #" cfsqltype="cf_s ql_integer">
WHERE degreeid = <cfqueryparam value="#i#" cfsqltype="CF_S QL_INTEGER">
</cfquery>
<cfset counter = counter + 1>
</cfloop>[/CODE]
I wrote some CF code but it does not seems to be working
[CODE=cfm]<cfset oldorderlist = ValueList(infoN ote.reqid)>
<!--get current position -->
<cfset getcurrentposit ion =ListFindNoCase (oldorderlist,u rl.reqid)>
<!--remove the requirement from the list -->
<cfset oldorderlist =ListDeleteAt(o ldorderlist, getcurrentposit ion)>
<!--the lenght of the lsit -->
<cfset thelsitlen= ListLen(oldorde rlist)>
<cfoutput>#thel sitlen#</cfoutput>
<!--moving the position of the requirement-->
<cfif url.move EQ "moveUp">
<cfset newposition = getcurrentposit ion - 1>
<cfif newposition LT 1>
<cfset newposition = 1>
</cfif>
<cfelse>
<cfset newposition = getcurrentposit ion + 1>
<cfif newposition GT ListLen(oldorde rlist)>
<cfset newposition = thelistlen + 1>
</cfif>
</cfif>
<! add to list >
<cfif newposition GT thelistlen>
<cfset neworderlist = ListAppend(oldo rderlist, url.bookid)>
<cfelse>
<cfset neworderlist = ListInsertAt(ol dorderlist, newposition, url.reqid)>
</cfif>
<!-- loop through the list and update the database-->
<cfset counter = 1>
<cfloop index="i" list="#neworder list#">
<cfquery datasource="Hot Banana_Manager" >
UPDATE trnAcademicProg ramsAndRequirem entsMapping
SET sortorder = <cfqueryparam value="#counter #" cfsqltype="cf_s ql_integer">
WHERE degreeid = <cfqueryparam value="#i#" cfsqltype="CF_S QL_INTEGER">
</cfquery>
<cfset counter = counter + 1>
</cfloop>[/CODE]
Comment