Subversion Repositories DevTools

Rev

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