Subversion Repositories DevTools

Rev

Rev 161 | Rev 5590 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
119 ghuddy 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
 
25
	Public Property Let FormName ( sFormName )
26
		mFormName = sFormName
27
	End Property
28
 
29
	Public Property Let Method ( sMethod )
30
		mMethod = sMethod
31
	End Property
32
 
33
	Public Property Let Action ( sAction )
34
		mAction = sAction
35
	End Property
36
 
37
	Public Property Let OnSubmit ( sOnSubmit )
38
		mOnSubmit = "onSubmit='"& sOnSubmit &"'"
39
	End Property
40
 
41
	Public Property Let IsReadonlyAction ( IsReadonly )
42
		If IsReadonly = enumDB_YES Then
43
			msDisabled = " disabled "
44
 
45
		ElseIf IsReadonly = enumDB_NO Then
46
			msDisabled = NULL
47
		Else
48
			msDisabled = " disabled "
49
 
50
		End If
51
 
52
	End Property
53
 
54
	'-----------------------------------------------------------------------------------------------------------------
55
	Public Function Combo ( sName, aList, bOneBlank, sAttributes )
56
		'=== List Definition ===
57
		' Method expects list array to have 3 columns ( filed value, field name, word "selected" for selected item )
58
 
59
		Dim compSTR
60
		Dim rowNum, numOfRows
61
 
62
		compSTR = ""
63
 
64
		'/* Generate Combo */
65
 
66
		compSTR = compSTR &"<select name='"& sName &"' "& sAttributes &" "& msDisabled &">"
67
 
68
		'-- Blank Item --
69
		If bOneBlank Then compSTR = compSTR &"<option value=''></option>"
70
 
71
 
72
		If IsArray(aList) Then
73
 
74
			numOfRows = UBound( aList, 2 )
75
			For rowNum = 0 To numOfRows
76
			    compSTR = compSTR &"<option value='"& aList( 0, rowNum ) &"' "& aList( 2, rowNum ) &">"& aList( 1, rowNum ) &"</option>"
77
			Next
78
 
79
		End If
80
 
81
 
82
		compSTR = compSTR &"</select>"
83
 
84
		Combo = compSTR
85
	End Function
161 iaugusti 86
 
119 ghuddy 87
	'-----------------------------------------------------------------------------------------------------------------
161 iaugusti 88
    ' Combo_Multi
89
    ' Multi column combo
90
    '   - Uses a fixed length font to allow alignment of columns
91
    '     Column widths are specified
92
	'     Columns are separated by a "|" 
93
    '
94
    ' sName - Name of Combo
95
    ' aList - List array with the following columns:
96
	'      column key, column values (separated by comas), the word "selected" for selected item
97
	'   e.g  
98
	'      1, Jack, Smith, "W.A"
99
	'      2, Jill, Smith, "S.A", "selected"   
100
	' bOneBlank - to add a blank combo item 
101
	' sAttributes - HTML attributes
102
	' iColumnCount - The number of columns to be displayed in the combo.
103
	' sColumnWidth - csv string containing the combo column widths
104
	'
105
	Public Function Combo_Multi ( sName, aList, bOneBlank, sAttributes, iColumnCount, sColumnWidth)
106
		'=== List Definition ===
107
 
108
		Dim compSTR
109
		Dim rowNum, numOfRows, colNum
110
		Dim sColVals, sColVal, sPad
111
		Dim iColLen, iPadLen, iValLen, i
112
		Dim arrColWidths
113
 
114
		compSTR = ""
115
 
116
		'/* Generate Combo */		
117
		compSTR = compSTR &"<select name='"& sName &"' "& sAttributes & "  style='font-family:Courier New,Lucida Console' " &" "& msDisabled &">"
118
 
119
		'-- Blank Item --
120
		If bOneBlank Then compSTR = compSTR &"<option value=''></option>"		
121
 
122
		If IsArray(aList) Then			
123
			numOfRows = UBound( aList, 2 )
124
 
125
			For rowNum = 0 To numOfRows
126
			  ' format columns of row
127
			  arrColWidths = split(sColumnWidth,",")
128
  			  sColVals = ""
129
  			  For colNum = 0 To iColumnCount-1
130
  			    ' get column width
131
  			    iColLen = arrColWidths(colNum)
132
  			    ' format column
133
  			    sColVal = aList(colNum + 1, rowNum)
134
  			    if IsNull(sColVal) then sColVal = ""
135
  			    iValLen = Len(sColVal)
136
  			    iPadLen = iColLen - iValLen
137
  			    ' if column value length greater than truncate
138
  			    if iPadLen < 0 then
139
  			      iPadLen = 0
140
  			      sColVal = Mid(sColVal,1,iColLen)  ' truncate column value to column length
141
  			    end if  
142
                ' generate pad string with non-breaking spaces
143
                sPad = ""
144
  			    For i = 0 to iPadLen-1
145
			      sPad = sPad & "&nbsp;"
146
			    Next
147
		        sColVals = sColVals & " " & sColVal & sPad & " |"
148
 
149
			  Next
150
			  sColVals = Mid(sColVals,1,Len(sColVals)-1)
151
			  compSTR = compSTR &"<option value='"& aList( 0, rowNum ) &"' "& aList( iColumnCount + 1, rowNum ) &">"& sColVals &"</option>"
152
			Next
153
 
154
		End If
155
 
156
 
157
		compSTR = compSTR &"</select>"
158
 
159
		Combo_Multi = compSTR
160
	End Function
161
 
162
	'-----------------------------------------------------------------------------------------------------------------
119 ghuddy 163
	Private Function Advanced_Combo ( sName, sValue, aList, sAttributes, sMore, bForceDropdown )
164
		Dim compSTR
165
		Dim rowNum, numOfRows, Display
166
 
167
		compSTR = ""
168
 
169
		'--- Text Box ---
170
		compSTR = compSTR &"<input name='"& sName &"' type='text' "& sAttributes &" value='"& sValue &"' "& msDisabled &">"
171
 
172
 
173
		'--- Dropdown Button ---
174
		If IsNull(aList) OR (NOT IsNull(msDisabled)) Then
175
			compSTR = compSTR & LIMG_FORM_COMPONENT_DROP_DOWN_OFF
176
			Advanced_Combo = compSTR
177
			Exit Function
178
		End If
179
	   	compSTR = compSTR &"<a href='javascript:;' onClick=""ToggleDisplay('divDropDown"& sName &"');"">"& LIMG_FORM_COMPONENT_DROP_DOWN &"</a>"
180
 
181
 
182
		'-- Default dispaly value
183
		Display = "none"
184
		If bForceDropdown Then
185
			Display = "block"
186
		End If
187
 
188
 
189
		'--- Dropdown List ---
190
		compSTR = compSTR &"<DIV id='divDropDown"& sName &"' name='divDropDown"& sName &"' style='display:"& Display &";' ><div style='height:150px; overflow: auto;'>"
191
	    compSTR = compSTR &"<table width='100%' border='0' cellspacing='0' cellpadding='1'>"
192
		compSTR = compSTR &"<tr>"
193
	    compSTR = compSTR &" <td background='controls/ERGFormComponent/images/bg_table_border.gif'><table width='100%'  border='0' cellspacing='0' cellpadding='2'>"
194
 
195
		numOfRows = UBound( aList, 2 )
196
		For rowNum = 0 To numOfRows
197
		    compSTR = compSTR &"   <tr>"
198
		    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>"
199
		    compSTR = compSTR &"   </tr>"
200
		Next
201
 
202
		'-- Display More.. link if required
203
		If NOT IsNull(sMore) Then
204
			compSTR = compSTR &"   <tr>"
205
		    compSTR = compSTR &"     <td nowrap bgcolor='#FFFFFF'><a href='"& sMore &"' class='body_link'>More...</a></td>"
206
		    compSTR = compSTR &"   </tr>"
207
		End If
208
 
209
 
210
		compSTR = compSTR &" </table></td>"
211
	    compSTR = compSTR &"</tr>"
212
	    compSTR = compSTR &"</table>"
213
		compSTR = compSTR &"</div></DIV>"
214
 
215
		Advanced_Combo = compSTR
216
	End Function
217
	'-----------------------------------------------------------------------------------------------------------------
218
	Public Function ComboWithTextAndFilter ( sName, sValue, aList, sAttributes, sMore, bForceDropdown )
219
		ComboWithTextAndFilter = Advanced_Combo ( sName, sValue, aList, sAttributes, sMore, bForceDropdown )
220
	End Function
221
	'-----------------------------------------------------------------------------------------------------------------
222
	Public Function ComboWithText ( sName, sValue, aList, sAttributes )
223
		ComboWithText = Advanced_Combo ( sName, sValue, aList, sAttributes, NULL, FALSE )
224
	End Function
225
	'-----------------------------------------------------------------------------------------------------------------
226
	Public Function TextArea ( sName, sValue, nRows, nCols, sAttributes )
227
 
228
		TextArea = _
229
		"<textarea name='"& sName &"' rows='"& nRows &"' cols='"& nCols &"' "& sAttributes &" "& msDisabled &">"& sValue &"</textarea>"
230
 
231
	End Function
232
	'-----------------------------------------------------------------------------------------------------------------
233
	Public Function TextBox ( sName, sValue, sAttributes )
234
		TextBox = _
235
		"<input type='text' name='"& sName &"' "& sAttributes &" value='"& sValue &"' "& msDisabled &">"
236
 
237
	End Function
238
	'-----------------------------------------------------------------------------------------------------------------
239
	Public Function SubmitButton ( sValue, sAttributes )
240
		SubmitButton = _
241
		"<input type='submit' value='"& sValue &"' "& sAttributes &" "& msDisabled &">"
242
	End Function
243
	'-----------------------------------------------------------------------------------------------------------------
244
	Public Function CancelButton ( sValue, sAttributes, sURLreturn )
245
		CancelButton = _
246
		"<input type='reset' value='"& sValue &"' "& sAttributes &" onClick=""window.location='"& sURLreturn &"';"">"
247
	End Function
248
	'-----------------------------------------------------------------------------------------------------------------
249
	Public Function BackButton ( sValue, sAttributes )
250
		BackButton = _
251
		"<input type='reset' value='"& sValue &"' "& sAttributes &" onClick=""history.back();"">"
252
	End Function
253
	'-----------------------------------------------------------------------------------------------------------------
254
	Public Sub FormStart ()
255
		If IsNull(mFormName) Then Err.Raise 8, "Method FormComponent.FormStart", "Form Name is not defined."
256
		If IsNull(mAction) Then Err.Raise 8, "Method FormComponent.FormStart", "Action Filename is not defined."
257
 
258
 
259
		Response.write "<form name='"& mFormName &"' method='"& mMethod &"' action='"& mAction &"' "& mOnSubmit &">"
260
 
261
	End Sub
262
	'-----------------------------------------------------------------------------------------------------------------
263
	Public Sub FormEnd ()
264
		Response.write "</form>"
265
 
266
	End Sub
267
	'-----------------------------------------------------------------------------------------------------------------
268
	Private Sub Class_Initialize()
269
		'// Perform action on creation of object. e.g. Set myObj = New ThisClassName
270
 
271
		mFormName = NULL
272
		mMethod = "post"
273
		mAction = NULL
274
		mOnSubmit = NULL
275
		msDisabled = NULL
276
 
277
	End Sub
278
	'-----------------------------------------------------------------------------------------------------------------
279
	Private Sub Class_Terminate()
280
		'// Perform action on object disposal. e.g. Set myObj = Nothing
281
	End Sub
282
	'-----------------------------------------------------------------------------------------------------------------
283
End Class
284
%>