Hi, I am new to this board and this is my first post. I am working on page for Scouts-boys/girls where there are multiple unit sections. Currently all of the units have one total that is unallocated/allocated that shows at the bottom of the page. The totals are calculated when putting it in a text box and the totals are automatically configured. I am trying to get the page to show subtotals for each unit and then one grand total calculating all of the subtotals that shows at the bottom of ths page. I have tried several methods so far and I am able to get one unit to work but not all of them to calculate subtotals. I know this may be confusing but here is a link to what the page currently looks like: http://dev.trails-end.com/TESales/ad...BBE7474F0D53C6 What I want it to look like is to have subtotals under each unit:Troop, Den, Patrol and then a Grand Total at the bottom. I am not sure if I am allowed to do this but here is the code I have, I would appreciate anybody's help and input, Thank you: m_strBackgroundColor = "#ffffff" ' get values from session m_lngSessionGroupId = clng(rsSession("GroupID")) m_strSessionRole = rsSession("role") m_lngSessionActorID = clng(rsSession("ActorID")) m_lngSessionChangeUserID = clng(rsSession("ChangeUserID")) m_intSessionLevelID = rsSession("LevelID") 'clng()? m_strSessionDisplayName = rsSession("DisplayName") m_strAction = (Request("action")) m_strMode = (Request("mode")) 'if mode is not specified, set the mode to "View" except in the case where editing if (len(m_strMode) = 0) then if ((len(m_strAction) = 0) or (m_strAction = "ALLOCATE")) then m_strMode = "View" else m_strMode = "Edit" end if end if 'Get GroupID m_lngGroupId = (Request("GroupID")) if (len(cstr(m_lngGroupId)) = 0) then If m_intSessionLevelID = 4 or m_intSessionLevelID = 5 Then m_lngGroupId = m_lngSessionGroupId Else 'Required parameter not supplied, or invalid parameter supplied 'Generate and display error 'Set Fatal Error condition Call m_objError.LogError(CStr(m_objFormatData.funcFormatDate(m_objError, Cstr(Now()),"mm/dd/yy hh:mm:ss")), _ "TE10", _ "The supplied GroupID does not belong to a unit or sub-unit. Only LevelID 4 or 5 groups are permitted.", _ "An invalid identifier for a Unit or Sub-Unit was supplied. Only Unit and Sub-Unit identifiers are valid parameters.", _ "", _ cstr(m_strScriptName & "@Request(""GroupID"")"), _ "10") Call subManageError(m_blnHasErrorShown) m_blnIsFatalError = True End if 'else ' 'Check for GroupID with LevelID of 4 or 5 ' Call funcGetGroup(m_lngGroupId, g_lngCurrentSalesCycleId, m_rsGroup, m_blnGetGroupSuccess) ' If funcErrorFree() = True and m_blnGetGroupSuccess = True Then ' If (m_rsGroup.Fields("LevelID").Value = 4 or m_rsGroup.Fields("LevelID").Value = 5) = False Then ' 'Invalid parameter supplied ' 'Generate and display error ' 'Set Fatal Error condition ' Call m_objError.LogError(CStr(m_objFormatData.funcFormatDate(m_objError, Cstr(Now()),"mm/dd/yy hh:mm:ss")), _ ' "TE10", _ ' "The supplied GroupID does not belong to a unit or sub-unit. Only LevelID 4 or 5 groups are permitted.", _ ' "An invalid identifier for a Unit or Sub-Unit was supplied. Only Unit and Sub-Unit identifiers are valid parameters.", _ ' "", _ ' cstr(m_strScriptName & "@funcGetGroup"), _ ' "10") ' Call subManageError(m_blnHasErrorShown) ' m_blnIsFatalError = True ' Else ' 'Valid GroupID ' 'Get the Group's DisplayName ' m_strDisplayName = m_rsGroup.Fields("DisplayName").value ' End if ' Else ' m_blnIsFatalError = True ' End If end if 'Get Group DisplayName If IsEmpty(m_strDisplayName) Then m_strDisplayName = (Request("DisplayName")) if (len(m_strDisplayName) = 0) then 'Replace Javascript Escape Sequences m_strDisplayName = Replace(Replace(Replace(m_strDisplayName, "\\", "\"), "\""", """"), "\'", "'") 'm_strDisplayName = Replace(m_strDisplayName, "\'", "'") If m_intSessionLevelID = 4 or m_intSessionLevelID = 5 Then m_strDisplayName = m_strSessionDisplayName End if end if End if 'SubUnit's Parent Unit GroupID when a Unit has SubUnits If m_intSessionLevelID = 4 Then m_lngUnitGroupID = m_lngSessionGroupId m_strUnitDisplayName = m_strSessionDisplayName End If m_blnPrizeProgram = false m_htmlMain = "" m_strScoutRows = "" 'Build Page Title if m_strMode = "Edit" then m_strPageTitle = "Edit " & m_strDisplayName & " Scouts" elseif m_strMode = "View" then m_strPageTitle = m_strDisplayName & " Scouts and Order Forms" end if m_strOnLoad = "funcRefreshForm();" 'Check for Fatal Error Condition 'If Fatal Error, skip all page processing except to display error and build page footer. If m_blnIsFatalError = False Then 'mode switch dim m_lngSwitchGroupID dim m_strSwitchDisplayName if ((m_strAction = "VIEWMODE") or (m_strAction = "EDITMODE")) then if (m_strAction = "VIEWMODE") then m_strMode = "View" If m_intSessionLevelID <> 4 Then m_lngSwitchGroupID = m_lngGroupID m_strSwitchDisplayName = m_strDisplayName Else m_lngSwitchGroupID = m_lngUnitGroupID m_strSwitchDisplayName = m_strUnitDisplayName End if else m_strMode = "Edit" m_lngSwitchGroupID = m_lngGroupID m_strSwitchDisplayName = m_strDisplayName end if dim m_htmlRedirectLink m_htmlRedirectLink = m_strScriptName & "?GroupID=" & m_lngSwitchGroupID & "&DisplayName=" & Server.URLEncode(m_strSwitchDisplayName) & "&SID=" & SID & "&mode=" & m_strMode 'change to new mode Response.Redirect m_htmlRedirectLink end if '-------------get order types--------------- dim m_blnCouncilHasOrderTypes dim m_rsOrderTypes 'dim m_lngUnitsCouncilID set m_rsOrderTypes = Server.CreateObject("ADODB.recordset") 'm_lngUnitsCouncilID = clng(funcGetCouncilID(m_lngGroupID, clng(g_lngCurrentSalesCycleId))) 'If funcErrorFree() = False Then ' 'display error ' Call subManageError(m_blnHasErrorShown) ' 'Clear the error object's properties and then reset them. ' Call m_objError.ClearError ' Call subResetErrorObjectProperties 'End if dim m_blnShouldShowOrders m_blnShouldShowOrders = funcPermit("OR-PC-110-C") and funcPermit("OR-PC-110-E") 'and funcPermit("OR-PC-110-V") removed -jj set m_rsOrderTypes = funcGetUnitOrderTypes(m_lngGroupID,clng(g_lngCurrentSalesCycleId)) If funcErrorFree() = False Then 'Error is setup for display in the funcGetUnitOrderTypes method 'Clear the error object's properties and then reset them. Call m_objError.ClearError Call subResetErrorObjectProperties m_blnIsFatalError = True Else m_blnCouncilHasOrderTypes = Not (m_rsOrderTypes.BOF and m_rsOrderTypes.EOF) m_intNumberOfOrderTypes = m_rsOrderTypes.RecordCount End if 'removed jj : this is really not the right logic. the council has order types, so setting it to false gives wrong results ''RJO later branch off of m_blnShouldShowOrders throughout instead of on m_blnCouncilHasOrderTypes 'if (not m_blnShouldShowOrders) then ' m_blnCouncilHasOrderTypes = false ' m_intNumberOfOrderTypes = 0 'end if 'Check for fatal error state If m_blnIsFatalError = False Then dim m_strFormItem dim m_strFormValue dim m_arrFormItem dim m_strDateItem dim m_lngAddOrderTypeId dim m_intFormCounter m_intFormCounter = 0 '____________________________________________________________________________________________________________________________________BEGIN FORM POST for each m_strFormItem in Request.Form if (left(m_strFormItem,5) = "Dirty") then m_strFormValue = Request.Form(m_strFormItem) '************************************************ INSERT ************************************************* if (m_strFormValue = "INSERT") then m_arrFormItem = Split(m_strFormItem, "_") m_lngScoutID = m_arrFormItem(1) m_lngFailedScoutID = m_lngScoutID 'if user hasn't simultaneously checked the delete checkbox if IsEmpty(Request("Delete" & m_strDateItem)) then if ((trim(funcFormValue("FirstName")) <> "") and (trim(funcFormValue("LastInitial")) <> "")) then 'rjo - straight fields vs. change fields (3) 'TO DO: Add New Scout Indicator call m_objScoutAdmin.funcCreateScout(m_objError, m_lngGroupId,mc_strDefaultRole,funcFormValue("FirstName"),funcFormValue("LastInitial"),cdbl(funcBlank2Null(funcFormValue("Goal"))),funcCheck2Int(funcFormValue("WantPatch")),funcCheck2Int(funcFormValue("WantPin"))) if not funcIsObjectOK(m_objScoutAdmin, m_strScriptName & "m_objScoutAdmin.funcCreateScout()" ) then 'handle error CALL subManageError(m_blnHasErrorShown) m_blnIsInsertError = True 'Call subAddText( m_htmlScreenText, m_objScoutAdmin.Error.TEErrorMessage) 'm_dtPostedFailedInsertDate = m_dtAddDate m_objScoutAdmin.Error.ClearError 'repopulate error object Call subResetErrorObjectProperties end if end if end if <% Code (markup):
Continuation of 1st post: '************************************************ UPDATE ************************************************* elseif (m_strFormValue = "UPDATE") then m_arrFormItem = Split(m_strFormItem, "_") m_lngScoutID = m_arrFormItem(1) m_arrFormPost( m_intFormCounter, 0) = m_lngScoutID m_arrFormError( m_intFormCounter, 0) = m_lngScoutID 'Do the updates m_arrFormPost( m_intFormCounter, 1) = "???" 'not used 'TO DO: Add New Scout Indicator call m_objScoutAdmin.subUpdateScout(m_objError, clng(m_lngScoutID), funcFormValue("Role"),funcFormValue("UserName"),funcFormValue("Password"),funcFormValue("FirstName"),funcFormValue("LastInitial"),funcBlank2Null(funcFormValue("Goal")),funcCheck2Int(funcFormValue("WantPatch")), funcCheck2Int(funcFormValue("WantPin")), funcCheck2Int(funcFormValue("NewScout")) ) if not funcIsObjectOK(m_objScoutAdmin, m_strScriptName & "m_objScoutAdmin.subUpdateScout()" ) then 'if the update fails add it to the updateFailedIds string m_strUpdateFailedIds = m_strUpdateFailedIds & m_lngScoutID & "|" m_blnIsUpdateError = true 'build error messages into array for later use m_arrFormError( m_intFormCounter, 1) = m_objScoutAdmin.Error.TEErrorMessage m_objScoutAdmin.Error.ClearError 'repopulate error object Call subResetErrorObjectProperties end if '************************************************ ALLOCATE ************************************************* 'mostly same as "update"? elseif (m_strFormValue = "ALLOCATE") then m_arrFormItem = Split(m_strFormItem, "_") m_lngScoutID = m_arrFormItem(1) m_lngOrderTypeID = m_arrFormItem(2) m_arrFormPost( m_intFormCounter, 0) = m_lngScoutID m_arrFormError( m_intFormCounter, 0) = m_lngScoutID 'Do the updates m_arrFormPost( m_intFormCounter, 1) = "???" 'not used call m_objScoutsWithOrders.subModifyScoutAllocation(m_objError, clng(m_lngScoutID), clng(m_lngOrderTypeID), clng( funcBlank2Zero(Request.Form("Allocated_" & m_lngScoutID & "_" & m_lngOrderTypeID))) ) if not funcIsObjectOK(m_objScoutsWithOrders, m_strScriptName & "m_objScoutsWithOrders.subModifyScoutAllocation()" ) then 'if the update fails add it to the updateFailedIds string m_strUpdateFailedIds = m_strUpdateFailedIds & m_lngScoutID & "|" m_blnIsUpdateError = true 'build error messages into array for later use m_arrFormError( m_intFormCounter, 1) = m_objScoutsWithOrders.Error.TEErrorMessage m_objScoutsWithOrders.Error.ClearError 'repopulate error object Call subResetErrorObjectProperties end if end if 'm_strFormValue check '************************************************ DELETE ************************************************* elseif (left(m_strFormItem,6) = "Delete") then m_arrFormItem = Split(m_strFormItem, "_") m_lngScoutID = m_arrFormItem(1) m_arrFormError( m_intFormCounter, 0) = m_lngScoutID if isNumeric(m_lngScoutID) then call m_objScoutAdmin.subDeleteScout(m_objError, clng(m_lngScoutID)) if not funcIsObjectOK(m_objScoutAdmin, m_strScriptName & "m_objScoutAdmin.subDeleteScout()" ) then 'if the Delete fails add it to the updateFailedIds string m_strUpdateFailedIds = m_strUpdateFailedIds & clng(m_lngScoutID) & "|" m_blnIsUpdateError = true 'build error messages into array for later use m_arrFormError( m_intFormCounter, 1) = m_objScoutAdmin.Error.TEErrorMessage 'call subAddText(m_htmlScreenText, m_objScoutAdmin.Error.TEErrorMessage) m_objScoutAdmin.Error.ClearError 'repopulate error object Call subResetErrorObjectProperties end if 'error check end if 'isnumeric check end if 'm_strFormItem prefix check m_intFormCounter = m_intFormCounter + 1 next '____________________________________________________________________________________________________________________________________ ' END FORM POST if ((m_strAction = "UPDATE") or (m_strAction = "ALLOCATE")) then 'dim m_htmlRedirectLink m_htmlRedirectLink = m_strScriptName & "?GroupID=" & m_lngGroupID & "&DisplayName=" & Server.URLEncode(m_strDisplayName) & "&SID=" & SID & "&mode=" & m_strMode 'stay in same mode If ((not m_blnIsInsertError) and (not m_blnIsUpdateError)) then Response.Redirect m_htmlRedirectLink End If end if End if 'check for Fatal Error state End if 'check for Fatal Error state '*************************************************** VBSCRIPT FUNCTIONS ******************************************** function funcFormValue(ByVal v_strBaseName) funcFormValue = Request.Form(v_strBaseName & "_" & m_lngScoutID) end function 'sub subAddValidation(ByVal v_strInputName, ByVal v_strCondition, ByVal v_strMessage) ' m_strFormValidate = m_strFormValidate & v_strToAppend ' ' " if (" & v_strCondition & ") {" & vbCrLf & _ ' " alert(" & v_strMessage & ")" & vbCrLf & _ ' " document.forms[0]." & v_strInputName & ".focus()" & vbCrLf & _ ' " return false" & vbCrLf & _ ' " }" & vbCrLf & vbCrLf 'end sub 'subAddValidation function funcGetFormValue(ByVal v_lngOrderTypeId, ByVal v_arrFormPost) 'go thru the array and get the form value dim l_count dim l_strReturn l_strReturn = "" for l_count = 0 to UBOUND(v_arrFormPost) if clng(v_arrFormPost(l_count, 0)) = clng(v_lngorderTypeId) then l_strReturn = v_arrFormPost(l_count, 1) end if next funcGetFormValue = l_strReturn end function %> <script language="javascript"> // *************************************************** JAVASCRIPT FUNCTIONS ******************************************** <% '/*------------------------------------------------------------------------------------------------- 'Date Created: 4/5/2002 'Original Developer: Bret Updegraff '---------------------------------------------------------------------------------------------------' ' setPageAction() 'Purpose: This function was created to validate the form on this page '--------------------------------------------------------------------------------------------------- 'INPUT DESCRIPTION 'objForm The form on this page (this.form) 'v_action1 value for the action form field 'v_action2 value for the subAction form field 'OUTPUT DESCRIPTION ' 'RETURN DESCRIPTION ' This function will determine if we need to validate the form before we post it and ' post the form accordingly. '--------------------------------------------------------------------------------------------------- 'Revision History: 'DATE DEVELOPER PURPOSE '4.5.02 Bret Updegraff Development Complete '-------------------------------------------------------------------------------------------------*/ %> function setPageAction(objForm, v_action1, v_action2) { objForm.action.value = v_action1; if ((v_action1 == "VIEWMODE") || (v_action1 == "EDITMODE")) { // objForm.btnSave.disabled = true; objForm.submit(); return; } if (v_action1 == "DELETE") { blnDoSubmit = confirm('<% = funcMessage(118) %>'); if (blnDoSubmit) { // objForm.btnSave.disabled = true; objForm.submit(); } else { alert('<% = funcMessage(119) %>'); } } else { funcValidateForm( objForm ); } } <% '/*------------------------------------------------------------------------------------------------- 'Date Created: 4/5/2002 'Original Developer: Bret Updegraff '---------------------------------------------------------------------------------------------------' ' funcValidateForm() 'Purpose: This function was created to validate the form on this page '--------------------------------------------------------------------------------------------------- 'INPUT DESCRIPTION 'objForm The form on this page (this.form) 'OUTPUT DESCRIPTION 'alertBox Alerts the user to what he needs to fix on the form 'RETURN DESCRIPTION '--------------------------------------------------------------------------------------------------- 'Revision History: 'DATE DEVELOPER PURPOSE '4.5.02 Bret Updegraff Development Complete '-------------------------------------------------------------------------------------------------*/ %> function funcValidateForm( objForm ) { var l_strErrorMsg = ""; var l_blnErrorMsg = false; if (l_blnErrorMsg == true) { addFormError( l_strErrorMsg, '<% = funcMessage(48) %>'); alert(l_strErrorMsg); } else { if ((funcValidateNumbers()) && (funcValidateFormElements())) { //objForm.btnSave.disabled = true; if (objForm.action.value == 'UPDATE') { objForm.btnSave.disabled = true; } else { objForm.btnAllocate.disabled = true; } objForm.submit(); } } } Code (markup):
dim m_strScoutNewTableHeader dim m_strScoutOrderTable dim m_strScoutTable dim m_strScoutPrizeTable dim m_strScoutTotalTable dim m_strUnallocatedRow dim m_strTotalRow dim m_strNewScoutName 'column heading dim m_strNewScoutDescription 'description of column const mc_strNewScoutDefaultName = "New Scout" 'HTML specification for dagger character = † or †const mc_strNewScoutSymbol = "†" const mc_strReplacementGroupName = "%GroupName%" const mc_strReplacementGroupID = "%GroupID%" dim m_objData dim m_rsNewScout 'Get the council specific NewScout Name and Description set m_objData = Server.CreateObject("DataAccess.clsNoTransact") set m_rsNewScout = Server.CreateObject("ADODB.Recordset") set m_rsNewScout = m_objData.GetADORS(m_objError, "prCouncilNewScout_selCouncilNewScout", cstr(m_lngGroupID)) If funcAreRecordsetAndObjectOK(m_rsNewScout, m_objData, m_strScriptName & "@prCouncilNewScout_selCouncilNewScout") = False Then 'display error Call subManageError(m_blnHasErrorShown) 'Clear the error object's properties and then reset them. Call m_objError.ClearError Call subResetErrorObjectProperties Elseif (m_rsNewScout.EOF And m_rsNewScout.EOF) = False then m_strNewScoutName = funcNull2Blank(m_rsNewScout.Fields("Name").value) m_strNewScoutDescription = funcNull2Blank(m_rsNewScout.Fields("Description").Value) End if '====================================================== '===================== EDIT =========================== '====================================================== if m_strMode = "Edit" then dim m_blnHasPatchPinProgram m_blnHasPatchPinProgram = funcIsCouncilUsingPatchPinProgram(rsSession("GroupID"),rsSession("LevelID"),g_lngCurrentSalesCycleId) '== BEGIN EDIT Screen Table Headings ==' 'Expecting column heading name and description for the New Scout Indicator from the recordset. 'If error with recordset or no records, then a default column heading is used. 'TO DO: Add New Scout Indicator m_strScoutHeaderRow = "<tr><th colspan=""10"">Editing " & m_strDisplayName & "</th></tr>" & _ "<tr>" & _ "<td class=""collabel"" valign=""bottom"">Delete</td>" & _ "<td class=""collabel"" valign=""bottom"">First Name & Initial <span style=""VERTICAL-ALIGN: super;"">*</span></td>" & _ "<td class=""collabel"" valign=""bottom"">ID</td>" & _ "<td class=""collabel"" valign=""bottom"">" & mc_strNewScoutDefaultName & " <span style=""VERTICAL-ALIGN: super;"">" & mc_strNewScoutSymbol & "</td>" & _ "<td class=""collabel"" valign=""bottom"">Goal($)</td>" & _ "<td class=""collabel"" valign=""bottom"">Login</td>" & _ "<td class=""collabel"" valign=""bottom"">Password</td>" if m_blnHasPatchPinProgram then m_strScoutHeaderRow = m_strScoutHeaderRow & "<td class=""collabel"" valign=""bottom"">Scout Earns</td>" else m_strScoutHeaderRow = m_strScoutHeaderRow & "<td class=""collabel"" valign=""bottom""> </td>" end if m_strScoutHeaderRow = m_strScoutHeaderRow & "</tr>" '== END EDIT Screen Table Headings ==' set m_rsScouts = m_objScoutAdmin.funcGetScoutsInUnitForEdit(m_objError, m_lngGroupId, clng(g_lngCurrentSalesCycleId)) if not funcAreRecordsetAndObjectOK(m_rsScouts, m_objScoutAdmin, m_strScriptName & "m_objScoutAdmin.funcGetScoutsInUnitForEdit") Then 'handle error 'CALL subManageError(m_blnHasErrorShown) subAddHTML m_objScoutAdmin.Error.TEErrorMessage m_blnIsFatalError = True m_objScoutAdmin.Error.ClearError() 'repopulate error object Call subResetErrorObjectProperties else 'no errors if (not (m_rsScouts.EOF and m_rsScouts.BOF)) then 'if there are records m_rsScouts.MoveFirst() dim m_intScoutCounter 'Replace default New Scout column heading with the council specific value 'm_strNewScoutName = funcNull2Blank(m_rsScouts.Fields("NewScoutName").value) 'm_strNewScoutDescription = funcNull2Blank(m_rsScouts.Fields("NewScoutDescription").Value) If Len(m_strNewScoutName) > 0 And Len(m_strNewScoutDescription) > 0 Then m_strScoutHeaderRow = Replace(m_strScoutHeaderRow, mc_strNewScoutDefaultName, m_strNewScoutName) End if 'loop through each scout record for m_intScoutCounter = 1 to m_rsScouts.RecordCount m_lngScoutID = m_rsScouts("ScoutID") m_strFirstName = m_rsScouts("FirstName") m_strLastInitial = m_rsScouts("LastInitial") m_strScoutKey = m_rsScouts("ScoutKey") m_curGoal = m_rsScouts("Goal") m_strUserName = m_rsScouts("UserName") m_strPassword = m_rsScouts("Password") m_blnWantPatch = m_rsScouts("WantPatch") m_blnWantPin = m_rsScouts("WantPin") m_strRole = m_rsScouts("Role") 'TO DO: Add New Scout Indicator m_blnNewScout = m_rsScouts("NewScout") dim m_strTableErrorMessage dim m_strTableErrorRow 'Check for errors from update if m_blnIsUpdateError and InStr(1,m_strUpdateFailedIds, "|" & m_lngScoutID & "|") > 0 then m_strTableErrorMessage = funcGetFormValue( m_lngScoutID, m_arrFormError) m_strTableErrorRow = "<tr bgColor=""" & m_colHighlight & """><td colspan=""11"">" & m_strTableErrorMessage & "</td></tr>" subAddHTML m_strTableErrorRow m_strFirstName = funcFormValue("FirstName") m_strLastInitial = funcFormValue("LastInitial") m_curGoal = funcFormValue("Goal") m_strUserName = funcFormValue("UserName") m_strPassword = funcFormValue("Password") m_blnWantPatch = funcCheck2Int(funcFormValue("WantPatch")) m_blnWantPin = funcCheck2Int(funcFormValue("WantPin")) 'TO DO: Add New Scout Indicator m_blnNewScout = funcCheck2Int(funcFormValue("NewScout")) end if 'blnUpdError Code (markup):