Rev 6986 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<%'============================================================='//'// Form Component'//'// version: 1.1'// last modified: 19-Aug-2004 13:47 by Sasha Vukovic'=============================================================%><%'------------- GLOBALS --------------Const LIMG_FORM_COMPONENT_DROP_DOWN = "<img src='controls/ERGFormComponent/images/bi_dropdown.gif' width='15' height='16' border='0' hspace='2' align='absmiddle'>"Const LIMG_FORM_COMPONENT_DROP_DOWN_OFF = "<img src='controls/ERGFormComponent/images/bi_dropdown_off.gif' width='15' height='16' border='0' align='absmiddle' hspace='2'>"'------------------------------------%><%Class FormComponentPrivate mFormNamePrivate mMethodPrivate mActionPrivate mOnSubmitPrivate msDisabledPrivate mClassPublic Property Let FormName ( sFormName )mFormName = sFormNameEnd PropertyPublic Property Let Method ( sMethod )mMethod = sMethodEnd PropertyPublic Property Let Action ( sAction )mAction = sActionEnd PropertyPublic Property Let FormClass ( sClass )mClass = sClassEnd PropertyPublic Property Let OnSubmit ( sOnSubmit )mOnSubmit = "onSubmit='"& sOnSubmit &"'"End PropertyPublic Property Let IsReadonlyAction ( IsReadonly )If IsReadonly = enumDB_YES ThenmsDisabled = " disabled "ElseIf IsReadonly = enumDB_NO ThenmsDisabled = NULLElsemsDisabled = " disabled "End IfEnd Property'-----------------------------------------------------------------------------------------------------------------Public Function Combo ( sName, aList, bOneBlank, sAttributes )'=== List Definition ===' Method expects list array to have 3 columns ( filed value, field name, word "selected" for selected item )Dim compSTRDim rowNum, numOfRowscompSTR = ""'/* Generate Combo */compSTR = compSTR &"<select name='"& sName &"' "& sAttributes &" "& msDisabled &">"'-- Blank Item --If bOneBlank Then compSTR = compSTR &"<option value='' >-- Select One --</option>"If IsArray(aList) ThennumOfRows = UBound( aList, 2 )For rowNum = 0 To numOfRowscompSTR = compSTR &"<option value='"& aList( 0, rowNum ) &"' "& aList( 2, rowNum ) &">"& aList( 1, rowNum ) &"</option>"NextEnd IfcompSTR = compSTR &"</select>"Combo = compSTREnd Function'-----------------------------------------------------------------------------------------------------------------' Combo_Multi' Multi column combo' - Uses a fixed length font to allow alignment of columns' Column widths are specified' Columns are separated by a "|"'' sName - Name of Combo' aList - List array with the following columns:' column key, column values (separated by comas), the word "selected" for selected item' e.g' 1, Jack, Smith, "W.A"' 2, Jill, Smith, "S.A", "selected"' bOneBlank - to add a blank combo item' sAttributes - HTML attributes' iColumnCount - The number of columns to be displayed in the combo.' sColumnWidth - csv string containing the combo column widths'Public Function Combo_Multi ( sName, aList, bOneBlank, sAttributes, iColumnCount, sColumnWidth)'=== List Definition ===Dim compSTRDim rowNum, numOfRows, colNumDim sColVals, sColVal, sPadDim iColLen, iPadLen, iValLen, iDim arrColWidthscompSTR = ""'/* Generate Combo */compSTR = compSTR &"<select name='"& sName &"' "& sAttributes & " style='font-family:Courier New,Lucida Console' " &" "& msDisabled &">"'-- Blank Item --If bOneBlank Then compSTR = compSTR &"<option value=''></option>"If IsArray(aList) ThennumOfRows = UBound( aList, 2 )For rowNum = 0 To numOfRows' format columns of rowarrColWidths = split(sColumnWidth,",")sColVals = ""For colNum = 0 To iColumnCount-1' get column widthiColLen = arrColWidths(colNum)' format columnsColVal = aList(colNum + 1, rowNum)if IsNull(sColVal) then sColVal = ""iValLen = Len(sColVal)iPadLen = iColLen - iValLen' if column value length greater than truncateif iPadLen < 0 theniPadLen = 0sColVal = Mid(sColVal,1,iColLen) ' truncate column value to column lengthend if' generate pad string with non-breaking spacessPad = ""For i = 0 to iPadLen-1sPad = sPad & " "NextsColVals = sColVals & " " & sColVal & sPad & " |"NextsColVals = Mid(sColVals,1,Len(sColVals)-1)compSTR = compSTR &"<option value='"& aList( 0, rowNum ) &"' "& aList( iColumnCount + 1, rowNum ) &">"& sColVals &"</option>"NextEnd IfcompSTR = compSTR &"</select>"Combo_Multi = compSTREnd Function'-----------------------------------------------------------------------------------------------------------------Private Function Advanced_Combo ( sName, sValue, aList, sAttributes, sMore, bForceDropdown )Dim compSTRDim rowNum, numOfRows, DisplaycompSTR = ""'--- Text Box ---compSTR = compSTR &"<input name='"& sName &"' type='text' "& sAttributes &" value='"& sValue &"' "& msDisabled &">"'--- Dropdown Button ---If IsNull(aList) OR (NOT IsNull(msDisabled)) ThencompSTR = compSTR & LIMG_FORM_COMPONENT_DROP_DOWN_OFFAdvanced_Combo = compSTRExit FunctionEnd IfcompSTR = compSTR &"<span class=pointer onClick=""ToggleDisplay('divDropDown"& sName &"');"">"& LIMG_FORM_COMPONENT_DROP_DOWN &"</span>"'-- Default dispaly valueDisplay = "none"If bForceDropdown ThenDisplay = "block"End If'--- Dropdown List ---compSTR = compSTR &"<DIV id='divDropDown"& sName &"' name='divDropDown"& sName &"' style='display:"& Display &";' ><div style='height:150px; overflow: auto;'>"compSTR = compSTR &"<table width='100%' border='0' cellspacing='0' cellpadding='1'>"compSTR = compSTR &"<tr>"compSTR = compSTR &" <td background='controls/ERGFormComponent/images/bg_table_border.gif'><table width='100%' border='0' cellspacing='0' cellpadding='2'>"numOfRows = UBound( aList, 2 )For rowNum = 0 To numOfRowscompSTR = compSTR &" <tr>"compSTR = compSTR &" <td nowrap bgcolor='#FFFFFF'><span class='menu_link pointer' onClick="""& mFormName &"."& sName &".value = '"& aList(1, rowNum) &"';ToggleDisplay('divDropDown"& sName &"');"">"& aList(1, rowNum) &"</span></td>"compSTR = compSTR &" </tr>"Next'-- Display More.. link if requiredIf NOT IsNull(sMore) ThencompSTR = compSTR &" <tr>"compSTR = compSTR &" <td nowrap bgcolor='#FFFFFF'><a href='"& sMore &"' class='body_link'>More...</a></td>"compSTR = compSTR &" </tr>"End IfcompSTR = compSTR &" </table></td>"compSTR = compSTR &"</tr>"compSTR = compSTR &"</table>"compSTR = compSTR &"</div></DIV>"Advanced_Combo = compSTREnd Function'-----------------------------------------------------------------------------------------------------------------Public Function ComboWithTextAndFilter ( sName, sValue, aList, sAttributes, sMore, bForceDropdown )ComboWithTextAndFilter = Advanced_Combo ( sName, sValue, aList, sAttributes, sMore, bForceDropdown )End Function'-----------------------------------------------------------------------------------------------------------------Public Function ComboWithText ( sName, sValue, aList, sAttributes )ComboWithText = Advanced_Combo ( sName, sValue, aList, sAttributes, NULL, FALSE )End Function'-----------------------------------------------------------------------------------------------------------------Public Function TextArea ( sName, sValue, nRows, nCols, sAttributes )TextArea = _"<textarea name='"& sName &"' rows='"& nRows &"' cols='"& nCols &"' "& sAttributes &" "& msDisabled &">"& sValue &"</textarea>"End Function'-----------------------------------------------------------------------------------------------------------------Public Function TextBox ( sName, sValue, sAttributes )TextBox = _"<input type='text' name='"& sName &"' "& sAttributes &" value='"& JSEncode(sValue) &"' "& msDisabled &">"End Function'-----------------------------------------------------------------------------------------------------------------Public Function SubmitButton ( sValue, sAttributes )SubmitButton = _"<input type='submit' value='"& sValue &"' "& sAttributes &" "& msDisabled &">"End Function'-----------------------------------------------------------------------------------------------------------------Public Function CancelButton ( sValue, sAttributes, sURLreturn )CancelButton = _"<input type='reset' value='"& sValue &"' "& sAttributes &" onClick=""window.location='"& sURLreturn &"';"">"End Function'-----------------------------------------------------------------------------------------------------------------Public Function BackButton ( sValue, sAttributes )BackButton = _"<input type='reset' value='"& sValue &"' "& sAttributes &" onClick=""history.back();"">"End Function'-----------------------------------------------------------------------------------------------------------------Public Sub FormStart ()If IsNull(mFormName) Then Err.Raise 8, "Method FormComponent.FormStart", "Form Name is not defined."If IsNull(mAction) Then Err.Raise 8, "Method FormComponent.FormStart", "Action Filename is not defined."Dim formClass : formClass = ""if NOT isNull(mClass) Thenformclass = " class='" & mClass & "'"End IfResponse.write "<form "& formClass & "name='"& mFormName &"' method='"& mMethod &"' action='"& mAction &"' "& mOnSubmit &">"End Sub'-----------------------------------------------------------------------------------------------------------------Public Sub FormEnd ()Response.write "</form>"End Sub'-----------------------------------------------------------------------------------------------------------------Private Sub Class_Initialize()'// Perform action on creation of object. e.g. Set myObj = New ThisClassNamemFormName = NULLmMethod = "post"mAction = NULLmOnSubmit = NULLmsDisabled = NULLmClass = NULLEnd Sub'-----------------------------------------------------------------------------------------------------------------Private Sub Class_Terminate()'// Perform action on object disposal. e.g. Set myObj = NothingEnd Sub'-----------------------------------------------------------------------------------------------------------------End Class%>