<%if request.Form("frmSubmit") = "Update" thentoday = now
if request("strComplete_" & i) ="true" then
strComplete = 1
else
strComplete = 0
end if
'////make Array from "FormComplete" form elements
For each item in Request.Form
If Left(item,12) = "strComplete_" Then
iFormComplete = item & (request.form(item)) 'get form item name and value
iFormComplete = replace(iFormComplete, "strComplete_", "") 'remove "strComplete_" from each form item
strFormComplete = strFormComplete & iFormComplete & "," 'add comma after each
End If
Next
If len(strFormComplete)>0 then
strFormComplete = left(strFormComplete, (len(strFormComplete) -1)) 'remove last comma
arrFormComplete = split(strFormComplete, ",") 'make array
End If
'///////////////////////////////////////////////////
'////begin - make recordset
strOrder = "AMS_ContentOverview.CourseID"
strSQL = "SELECT AMS_CourseCategory.CourseCatDesc, AMS_ContentOverview.CourseID, AMS_ContentOverview.Complete "_
&"FROM AMS_ContentOverview INNER JOIN "_
&"AMS_Courses ON AMS_ContentOverview.CourseID = AMS_Courses.CourseID INNER JOIN "_
&"AMS_CourseCategory ON AMS_Courses.CourseCatID = AMS_CourseCategory.CourseCatID "_
&"ORDER BY " & strOrder
'Create a Recordset
Dim objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.cursorlocation = 3
objRS.Open strSQL, objConnection
dim arrVarFieldNames, arrDbVals
arrVarFieldNames = Array("CourseID", "Complete")
arrDbVals= objRS.GetRows(,,arrVarFieldNames)
dim iRowLoop, iColLoop, zRowLoop, strChange, tempDbValsCase
'////loop through db values and compare to form values in inner loop
for iRowLoop = 0 to ubound(arrDbVals, 2)
'////loop through form values for comparison to db values in outer loop
for zRowLoop = 0 to ubound(arrFormComplete)
tempDbValsCase = lcase(trim(arrDbVals(1, iRowLoop)))
'////perform comparison of db value to form value
if (mid(trim(arrFormComplete(zRowLoop)),1,8) = trim(arrDbVals(0, iRowLoop))) AND (mid(trim(arrFormComplete(zRowLoop)),9) <> tempDbValsCase) then
'////make string of changed value id's
dim strFormAllVals
strFormAllVals = arrFormComplete(zRowLoop)
strChange = strChange & strFormAllVals & ","
end if
next
next
'//////////make array of changed value id's
If len(strChange)>0 then
'////trim off the trailing ","
strChange = left(strChange, (len(strChange) -1))
arrValsChange = split(strChange, ",")
'/////
dim strValsComplete, strValsInComplete
for i = 0 to ubound(arrValsChange)
dim strTempValsComplete, strTempValsInComplete
if mid(trim(arrValsChange(i)), 9) = "true" then
strTempValsComplete = trim(arrValsChange(i))
strTempValsComplete = replace(strTempValsComplete, "strComplete_", "")
strTempValsComplete = replace(strTempValsComplete, mid(strTempValsComplete, 9), "")
strValsComplete = strValsComplete & strTempValsComplete & ","
elseif mid(trim(arrValsChange(i)), 9) = "false" then
strTempValsInComplete = trim(arrValsChange(i))
strTempValsInComplete = replace(strTempValsInComplete, "strComplete_", "")
strTempValsInComplete = replace(strTempValsInComplete, mid(strTempValsInComplete, 9), "")
strValsInComplete = strValsInComplete & strTempValsInComplete & ","
end if
next
'/////
If len(strValsComplete)>0 then
strValsComplete = left(strValsComplete, (len(strValsComplete) -1))
arrValsComplete = split(strValsComplete, ",")
End If
If len(strValsInComplete)>0 then
strValsInComplete = left(strValsInComplete, (len(strValsInComplete) -1))
arrValsInComplete = split(strValsInComplete, ",")
End If
'/////
If ((len(strValsComplete)>0) or (len(strValsInComplete>0))) then
If len(strValsComplete)>0 then
strSql = ""
table="AMS_ContentOverview"
strSql = strSql & "UPDATE " & table & " SET Complete = 1, LastUpdate = '"& today & "' WHERE "
for i = 0 to ubound(arrValsComplete)
if i = 0 then
strSql = strSql & "CourseID = "& arrValsComplete(i)
else
'only add the " OR " if this is not the first value
strSql = strSql & " OR CourseID = "& arrValsComplete(i)
end if
next
%>
<!--#include virtual="/common/db/QryDbCommand.asp"-->
<%
End If
'////
If len(strValsInComplete)>0 then
strSql = ""
table="AMS_ContentOverview"
strSql = strSql & "UPDATE " & table & " SET Complete = 0, LastUpdate = '"& today & "' WHERE "
for i = 0 to ubound(arrValsInComplete)
if i = 0 then
strSql = strSql & "CourseID = "& arrValsInComplete(i)
else
'only add the " OR " if this is not the first value
strSql = strSql & " OR CourseID = "& arrValsInComplete(i)
end if
next
%>
<!--#include virtual="/common/db/QryDbCommand.asp"-->