Subversion Repositories DevTools

Rev

Rev 13 | Go to most recent revision | 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 FormComponent
        
        Private mFormName
        Private mMethod
        Private mAction
        Private mOnSubmit
        Private msDisabled
        
        Public Property Let FormName ( sFormName )
                mFormName = sFormName
        End Property
        
        Public Property Let Method ( sMethod )
                mMethod = sMethod
        End Property
        
        Public Property Let Action ( sAction )
                mAction = sAction
        End Property
        
        Public Property Let OnSubmit ( sOnSubmit )
                mOnSubmit = "onSubmit='"& sOnSubmit &"'"
        End Property
        
        Public Property Let IsReadonlyAction ( IsReadonly )
                If IsReadonly = enumDB_YES Then
                        msDisabled = " disabled "
                        
                ElseIf IsReadonly = enumDB_NO Then
                        msDisabled = NULL
                Else
                        msDisabled = " disabled "
                        
                End If
                
        End 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 compSTR
                Dim rowNum, numOfRows
                
                compSTR = ""
                
                '/* Generate Combo */
                
                compSTR = compSTR &"<select name='"& sName &"' "& sAttributes &" "& msDisabled &">"
                
                '-- Blank Item --
                If bOneBlank Then compSTR = compSTR &"<option value=''></option>"
                
                
                If IsArray(aList) Then
                        
                        numOfRows = UBound( aList, 2 )
                        For rowNum = 0 To numOfRows
                            compSTR = compSTR &"<option value='"& aList( 0, rowNum ) &"' "& aList( 2, rowNum ) &">"& aList( 1, rowNum ) &"</option>"
                        Next
                        
                End If
                
                
                compSTR = compSTR &"</select>"
                
                Combo = compSTR
        End Function
        '-----------------------------------------------------------------------------------------------------------------
        Private Function Advanced_Combo ( sName, sValue, aList, sAttributes, sMore, bForceDropdown )
                Dim compSTR
                Dim rowNum, numOfRows, Display
                
                compSTR = ""
                
                '--- Text Box ---
                compSTR = compSTR &"<input name='"& sName &"' type='text' "& sAttributes &" value='"& sValue &"' "& msDisabled &">"
                
                
                '--- Dropdown Button ---
                If IsNull(aList) OR (NOT IsNull(msDisabled)) Then
                        compSTR = compSTR & LIMG_FORM_COMPONENT_DROP_DOWN_OFF
                        Advanced_Combo = compSTR
                        Exit Function
                End If
                compSTR = compSTR &"<a href='javascript:;' onClick=""ToggleDisplay('divDropDown"& sName &"');"">"& LIMG_FORM_COMPONENT_DROP_DOWN &"</a>"
                
                
                '-- Default dispaly value
                Display = "none"
                If bForceDropdown Then
                        Display = "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 numOfRows
                    compSTR = compSTR &"   <tr>"
                    compSTR = compSTR &"     <td nowrap bgcolor='#FFFFFF'><a href='javascript:;' class='menu_link' onClick="""& mFormName &"."& sName &".value = '"& aList(1, rowNum) &"';ToggleDisplay('divDropDown"& sName &"');"">"& aList(1, rowNum) &"</a></td>"
                    compSTR = compSTR &"   </tr>"
                Next
                
                '-- Display More.. link if required
                If NOT IsNull(sMore) Then
                        compSTR = compSTR &"   <tr>"
                    compSTR = compSTR &"     <td nowrap bgcolor='#FFFFFF'><a href='"& sMore &"' class='body_link'>More...</a></td>"
                    compSTR = compSTR &"   </tr>"
                End If
                
                
                compSTR = compSTR &" </table></td>"
            compSTR = compSTR &"</tr>"
            compSTR = compSTR &"</table>"
                compSTR = compSTR &"</div></DIV>"
                
                Advanced_Combo = compSTR
        End 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='"& sValue &"' "& msDisabled &">"
                
        End Function
        '-----------------------------------------------------------------------------------------------------------------
        Public Function CheckBox ( sName, sValue, sAttributes )
                CheckBox = _
                "<input type='checkbox' name='"& sName &"' "& sAttributes &" value='"& 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."
                
                
                Response.write "<form 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 ThisClassName
                
                mFormName = NULL
                mMethod = "post"
                mAction = NULL
                mOnSubmit = NULL
                msDisabled = NULL
                
        End Sub
        '-----------------------------------------------------------------------------------------------------------------
        Private Sub Class_Terminate()
                '// Perform action on object disposal. e.g. Set myObj = Nothing
        End Sub
        '-----------------------------------------------------------------------------------------------------------------
End Class
%>