Subversion Repositories DevTools

Rev

Rev 64 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
64 jtweddle 1
<%
2
'=============================================================
3
'//
4
'//						Form Component
5
'//
6
'// version: 		1.1
7
'//	last modified: 	19-Aug-2004 13:47 by Sasha Vukovic
8
'=============================================================
9
%>
10
<%
11
'------------- GLOBALS --------------
12
Const LIMG_FORM_COMPONENT_DROP_DOWN = "<img src='controls/ERGFormComponent/images/bi_dropdown.gif' width='15' height='16' border='0' hspace='2' align='absmiddle'>"
13
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'>"
14
'------------------------------------
15
%>
16
<%
17
Class FormComponent
18
 
19
	Private mFormName
20
	Private mMethod
21
	Private mAction
22
	Private mOnSubmit
23
	Private msDisabled
24
	Private mEnctype
25
 
26
	Public Property Let FormName ( sFormName )
27
		mFormName = sFormName
28
	End Property
29
 
30
	Public Property Let Method ( sMethod )
31
		mMethod = sMethod
32
	End Property
33
 
34
	Public Property Let Action ( sAction )
35
		mAction = sAction
36
	End Property
37
 
38
	Public Property Let OnSubmit ( sOnSubmit )
39
		mOnSubmit = "onSubmit='"& sOnSubmit &"'"
40
	End Property
41
 
42
	Public Property Let Enctype ( sEnctype)
43
		mEnctype = sEnctype
44
	End Property	
45
 
46
	Public Property Let IsReadonlyAction ( IsReadonly )
47
		If IsReadonly = enumDB_YES Then
48
			msDisabled = " disabled "
49
 
50
		ElseIf IsReadonly = enumDB_NO Then
51
			msDisabled = NULL
52
		Else
53
			msDisabled = " disabled "
54
 
55
		End If
56
 
57
	End Property
58
 
59
	'-----------------------------------------------------------------------------------------------------------------
60
	Public Function Combo ( sName, aList, bOneBlank, sAttributes )
61
		'=== List Definition ===
62
		' Method expects list array to have 3 columns ( filed value, field name, word "selected" for selected item )
63
 
64
		Dim compSTR
65
		Dim rowNum, numOfRows
66
 
67
		compSTR = ""
68
 
69
		'/* Generate Combo */
70
 
71
		compSTR = compSTR &"<select name='"& sName &"' "& sAttributes &" "& msDisabled &">"
72
 
73
		'-- Blank Item --
74
		If bOneBlank Then compSTR = compSTR &"<option value=''></option>"
75
 
76
 
77
		If IsArray(aList) Then
78
 
79
			numOfRows = UBound( aList, 2 )
80
			For rowNum = 0 To numOfRows
81
			    compSTR = compSTR &"<option value='"& aList( 0, rowNum ) &"' "& aList( 2, rowNum ) &">"& aList( 1, rowNum ) &"</option>"
82
			Next
83
 
84
		End If
85
 
86
 
87
		compSTR = compSTR &"</select>"
88
		Combo = compSTR
89
	End Function
90
	'-----------------------------------------------------------------------------------------------------------------
91
	Private Function Advanced_Combo ( sName, sValue, aList, sAttributes, sMore, bForceDropdown )
92
		Dim compSTR
93
		Dim rowNum, numOfRows, Display
94
 
95
		compSTR = ""
96
 
97
		'--- Text Box ---
98
		compSTR = compSTR &"<input name='"& sName &"' type='text' "& sAttributes &" value='"& sValue &"' "& msDisabled &">"
99
 
100
 
101
		'--- Dropdown Button ---
102
		If IsNull(aList) OR (NOT IsNull(msDisabled)) Then
103
			compSTR = compSTR & LIMG_FORM_COMPONENT_DROP_DOWN_OFF
104
			Advanced_Combo = compSTR
105
			Exit Function
106
		End If
107
	   	compSTR = compSTR &"<a href='javascript:;' onClick=""ToggleDisplay('divDropDown"& sName &"');"">"& LIMG_FORM_COMPONENT_DROP_DOWN &"</a>"
108
 
109
 
110
		'-- Default dispaly value
111
		Display = "none"
112
		If bForceDropdown Then
113
			Display = "block"
114
		End If
115
 
116
 
117
		'--- Dropdown List ---
118
		compSTR = compSTR &"<DIV id='divDropDown"& sName &"' name='divDropDown"& sName &"' style='display:"& Display &";' ><div style='height:150px; overflow: auto;'>"
119
	    compSTR = compSTR &"<table width='100%' border='0' cellspacing='0' cellpadding='1'>"
120
		compSTR = compSTR &"<tr>"
121
	    compSTR = compSTR &" <td background='controls/ERGFormComponent/images/bg_table_border.gif'><table width='100%'  border='0' cellspacing='0' cellpadding='2'>"
122
 
123
		numOfRows = UBound( aList, 2 )
124
		For rowNum = 0 To numOfRows
125
		    compSTR = compSTR &"   <tr>"
126
		    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>"
127
		    compSTR = compSTR &"   </tr>"
128
		Next
129
 
130
		'-- Display More.. link if required
131
		If NOT IsNull(sMore) Then
132
			compSTR = compSTR &"   <tr>"
133
		    compSTR = compSTR &"     <td nowrap bgcolor='#FFFFFF'><a href='"& sMore &"' class='body_link'>More...</a></td>"
134
		    compSTR = compSTR &"   </tr>"
135
		End If
136
 
137
 
138
		compSTR = compSTR &" </table></td>"
139
	    compSTR = compSTR &"</tr>"
140
	    compSTR = compSTR &"</table>"
141
		compSTR = compSTR &"</div></DIV>"
142
 
143
		Advanced_Combo = compSTR
144
	End Function
145
	'-----------------------------------------------------------------------------------------------------------------
146
	Public Function ComboWithTextAndFilter ( sName, sValue, aList, sAttributes, sMore, bForceDropdown )
147
		ComboWithTextAndFilter = Advanced_Combo ( sName, sValue, aList, sAttributes, sMore, bForceDropdown )
148
	End Function
149
	'-----------------------------------------------------------------------------------------------------------------
150
	Public Function ComboWithText ( sName, sValue, aList, sAttributes )
151
		ComboWithText = Advanced_Combo ( sName, sValue, aList, sAttributes, NULL, FALSE )
152
	End Function
153
	'-----------------------------------------------------------------------------------------------------------------
154
	Public Function TextArea ( sName, sValue, nRows, nCols, sAttributes )
155
 
156
		TextArea = _
157
		"<textarea name='"& sName &"' rows='"& nRows &"' cols='"& nCols &"' "& sAttributes &" "& msDisabled &">"& sValue &"</textarea>"
158
 
159
	End Function
160
	'-----------------------------------------------------------------------------------------------------------------
161
	Public Function TextBox ( sName, sValue, sAttributes )
162
		TextBox = _
163
		"<input type='text' name='"& sName &"' "& sAttributes &" value='"& sValue &"' "& msDisabled &">"
164
 
165
	End Function
166
	'-----------------------------------------------------------------------------------------------------------------
167
	Public Function CheckBox ( sName, sValue, sAttributes )
168
		CheckBox = _
169
		"<input type='checkbox' name='"& sName &"' "& sAttributes &" value='"& sValue &"' "& msDisabled &">"
170
 
171
	End Function	
172
	'-----------------------------------------------------------------------------------------------------------------
173
	Public Function SubmitButton ( sValue, sAttributes )
174
		SubmitButton = _
175
		"<input type='submit' value='"& sValue &"' "& sAttributes &" "& msDisabled &">"
176
	End Function
177
	'-----------------------------------------------------------------------------------------------------------------
178
	Public Function CancelButton ( sValue, sAttributes, sURLreturn )
179
		CancelButton = _
180
		"<input type='reset' value='"& sValue &"' "& sAttributes &" onClick=""window.location='"& sURLreturn &"';"">"
181
	End Function
182
	'-----------------------------------------------------------------------------------------------------------------
183
	Public Function BackButton ( sValue, sAttributes )
184
		BackButton = _
185
		"<input type='reset' value='"& sValue &"' "& sAttributes &" onClick=""history.back();"">"
186
	End Function
187
	'-----------------------------------------------------------------------------------------------------------------
188
	Public Sub FormStart ()
189
		If IsNull(mFormName) Then Err.Raise 8, "Method FormComponent.FormStart", "Form Name is not defined."
190
		If IsNull(mAction) Then Err.Raise 8, "Method FormComponent.FormStart", "Action Filename is not defined."
191
 
192
 
193
		Response.write "<form name='"& mFormName &"' method='"& mMethod &"' enctype='"& mEnctype &"' action='"& mAction &"' "& mOnSubmit &">"
194
 
195
	End Sub
196
	'-----------------------------------------------------------------------------------------------------------------
197
	Public Sub FormEnd ()
198
		Response.write "</form>"
199
 
200
	End Sub
201
	'-----------------------------------------------------------------------------------------------------------------
202
	Private Sub Class_Initialize()
203
		'// Perform action on creation of object. e.g. Set myObj = New ThisClassName
204
 
205
		mFormName = NULL
206
		mMethod = "post"
207
		mAction = NULL
208
		mOnSubmit = NULL
209
		msDisabled = NULL
210
		mEnctype = NULL
211
 
212
	End Sub
213
	'-----------------------------------------------------------------------------------------------------------------
214
	Private Sub Class_Terminate()
215
		'// Perform action on object disposal. e.g. Set myObj = Nothing
216
	End Sub
217
	'-----------------------------------------------------------------------------------------------------------------
218
End Class
219
%>