|
Library of HTML Commands by Phil
Paxton
©1999,2000 by Phil Paxton
Subroutines and Functions can be used, for example, to
provide a layer of abstraction over HTML.
filename=/learn/test/htmldemo.asp
<!--#include virtual="/learn/test/lib_htmlstuff.asp"-->
<html><head>
<title>libhtmldemo.asp by Phil Paxton</title></head>
<body>
<form action="lib_htmldemorespond.asp">
<%
Call Form_TextBox("first name","Fname",20,20,"")
response.write "<br>"
Call Form_TextBox("Last Name","Lname",20,20,"")
response.write "<br>"
Call Form_TextBox("City","cy",20,20,"")
response.write "<br>"
Call Form_TextBox("State","st",2,2,"")
response.write "<br>"
Call Form_TextBox("Zip Code","zp",10,10,"")
response.write "<br>"
Call Form_SubmitButton("Register Me","register")
%>
</form>
</body>
</html>
The library that enables this (named lib_htmlstuff.asp)
looks like:
filename=/learn/test/lib_htmlstuff.asp
<%
Sub Display( Text )
Response.Write( Text )
End Sub
'----------------------------------------------------------------
Sub HTML( Text )
Response.Write( Text )
End Sub
'----------------------------------------------------------------
Sub Test( Text )
Response.Write( Text )
End Sub
'----------------------------------------------------------------
Sub Form_HiddenField( Name, Value )
HTML "<INPUT "
Form_Parm_Type "Hidden"
Form_Parm_Name Name
Form_Parm_Value Value
HTML ">"
End Sub
'----------------------------------------------------------------
Sub Form_Label( Label, Control )
If Len(Label) > 0 Then
HTML "<label "
HTML "for=" & Control
HTML ">"
HTML "<strong>"
Display Label
HTML "</strong>"
HTML "</label>"
End If
End Sub
'----------------------------------------------------------------
Sub Form_TextBox( Label, Name, MaxLength, Size, Value )
Form_Label Label, Name
HTML "<input "
Form_Parm_Type "text"
Form_Parm_Name Name
Form_Parm_Size Size
Form_Parm_ID Name
Form_Parm_MaxLength MaxLength
Form_Parm_Value Value
HTML ">"
End Sub
'----------------------------------------------------------------
Sub Form_Password( Label, Name, MaxLength, Size, Value )
Form_Label Label, Name
HTML "<input "
Form_Parm_Type "password"
Form_Parm_Name Name
Form_Parm_Size Size
Form_Parm_ID Name
Form_Parm_MaxLength MaxLength
Form_Parm_Value Value
HTML ">"
End Sub
'----------------------------------------------------------------
Sub Form_ScrollingText( Label, Name, Rows, Cols, Value )
Form_Label Label, Name
HTML "<textarea "
Form_Parm_Name Name
If Len(Rows) > 0 Then
HTML "rows=" & Rows & " "
End If
If Len(Cols) > 0 Then
HTML "cols=" & Cols & " "
End If
Form_Parm_ID Name
HTML ">"
If Len(Value) > 0 Then
Display Value
End If
HTML "</textarea>"
End Sub
'----------------------------------------------------------------
Sub Form_ResetButton( Name, Value )
HTML "<input "
Form_Parm_Type "reset"
Form_Parm_Value Value
Form_Parm_Name Name
HTML ">"
End Sub
'----------------------------------------------------------------
Sub Form_CommandButton( Name, Value )
HTML "<input "
Form_Parm_Type "button"
Form_Parm_Value Value
Form_Parm_Name Name
HTML ">"
End Sub
'----------------------------------------------------------------
Sub Form_SubmitButton( Name, Value )
HTML "<input "
Form_Parm_Type "submit"
Form_Parm_Value Value
Form_Parm_Name Name
HTML ">"
End Sub
'----------------------------------------------------------------
Sub Form_RadioButton( Label, Name, Value, Checked )
HTML "<input "
Form_Parm_Type "radio"
Form_Parm_Value Value
Form_Parm_Name Name
Form_Parm_ID Name & Value
If Len(Checked) > 0 Then
If Checked Then
HTML " checked "
End If
End If
HTML ">"
Form_Label Label, Name & Value
End Sub
'----------------------------------------------------------------
Sub Form_Checkbox( Label, Name, Value, Checked )
Form_Label Label, Name
HTML "<INPUT "
Form_Parm_Type "checkbox"
Form_Parm_Name Name
Form_Parm_Value Value
If Len( Checked ) > 0 Then
If Checked = True Then
HTML " checked "
End If
End If
HTML ">"
'
End Sub
'----------------------------------------------------------------
Sub Form_Begin( Action )
HTML "<form "
HTML "method=post "
HTML "action =" & Chr(39) & Action & Chr(39) & " "
HTML ">"
End Sub
'----------------------------------------------------------------
Sub Form_End( Name, Value )
Form_HiddenField Name, Value
HTML "</FORM>"
End Sub
'----------------------------------------------------------------
Sub Form_Table_Begin( Border, Width )
HTML "<table "
If Len(Border) > 0 Then
HTML "border=" & Chr(39) & Border & Chr(39) & " "
End If
Form_Parm_Width Width
HTML ">"
End Sub
'----------------------------------------------------------------
Sub Form_Table_End()
HTML "</table>"
End Sub
'----------------------------------------------------------------
Sub Form_Table_Row_Begin( Dummy, Align, VAlign )
HTML "<tr "
Form_Parm_Align Align
Form_Parm_VAlign VAlign
HTML ">"
End Sub
'----------------------------------------------------------------
Sub Form_Table_Row_End( Dummy )
HTML "</tr>"
End Sub
'----------------------------------------------------------------
Sub Form_Table_Cell_Begin( Dummy, Width, Align, VAlign )
HTML "<td "
Form_Parm_Width Width
Form_Parm_Align Align
Form_Parm_VAlign VAlign
HTML ">"
End Sub
'----------------------------------------------------------------
Sub Form_Table_Cell_End( Dummy )
HTML "</td>"
End Sub
'----------------------------------------------------------------
Sub Form_ComboBox_Begin( Label, Name, Size, Multiple )
Form_Label Label, Name
HTML "<select "
Form_Parm_Name Name
Form_Parm_Size Size
If Len(Multiple) > 0 Then
If Multiple Then
HTML " multiple "
End If
End If
HTML ">"
End Sub
'----------------------------------------------------------------
Sub Form_ComboBox_Item( Value, Selected )
HTML "<option "
Form_Parm_Value Value
If Len(Selected) > 0 Then
If Selected Then
HTML " selected "
End If
End If
HTML ">"
End Sub
'----------------------------------------------------------------
Sub Form_ComboBox_End()
HTML "</select>"
End Sub
'----------------------------------------------------------------
Sub Form_Title( Title )
HTML "<title>"
Display Title
HTML "</title>"
End Sub
'----------------------------------------------------------------
Sub Form_Center( Text )
HTML "<p align=" & Chr(39) & "center" & Chr(39) & ">"
Display Text
HTML "</p>"
End Sub
'----------------------------------------------------------------
Sub Form_Left( Text )
HTML "<p align=" & Chr(39) & "left" & Chr(39) & ">"
Display Text
HTML "</p>"
End Sub
'----------------------------------------------------------------
Sub Form_Right( Text )
HTML "<p align=" & Chr(39) & "right" & Chr(39) & ">"
Display Text
HTML "</p>"
End Sub
'----------------------------------------------------------------
Sub Form_Parm_Align( Align )
If Len(Align) > 0 Then
Select Case UCase(Align)
Case "L", "LEFT"
Display " align=" & Chr(39) & "left" & Chr(39) & " "
Case "C", "CENTER"
Display " align=" & Chr(39) & "center" & Chr(39) & " "
Case "R", "RIGHT"
Display " align=" & Chr(39) & "right" & Chr(39) & " "
Case Else
End Select
End If
End Sub
'----------------------------------------------------------------
Sub Form_Parm_VAlign( VAlign )
If Len(VAlign) > 0 Then
Select Case UCase(VAlign)
Case "T", "TOP"
Display " align=" & Chr(39) & "top" & Chr(39) & " "
Case "C", "CENTER"
Display " align=" & Chr(39) & "center" & Chr(39) & " "
Case "B", "BOTTOM"
Display " align=" & Chr(39) & "bottom" & Chr(39) & " "
Case Else
End Select
End If
End Sub
'----------------------------------------------------------------
Sub Form_Parm_Name( Name )
If Len(Name) > 0 Then
Display " name=" & Chr(39) & Name & Chr(39) & " "
End If
End Sub
'----------------------------------------------------------------
Sub Form_Parm_Value( Value )
If Len(Value) > 0 Then
Display " value=" & Chr(39) & Value & Chr(39) & " "
End If
End Sub
'----------------------------------------------------------------
Sub Form_Parm_Type( TypeValue )
If Len(TypeValue) > 0 Then
Display " type=" & Chr(39) & TypeValue & Chr(39) & " "
End If
End Sub
'----------------------------------------------------------------
Sub Form_Parm_Size( Size )
If Len(Size) > 0 Then
Display " size=" & Size & " "
End If
End Sub
'----------------------------------------------------------------
Sub Form_Parm_ID( ID )
If Len(ID) > 0 Then
Display " id=" & Chr(39) & ID & Chr(39) & " "
End If
End Sub
'----------------------------------------------------------------
Sub Form_Parm_MaxLength( MaxLength )
If Len(MaxLength) > 0 Then
Display " maxlength=" & MaxLength
End If
End Sub
'----------------------------------------------------------------
Sub Form_Parm_Length( Length )
If Len(Length) > 0 Then
Display " length=" & Length
End If
End Sub
'----------------------------------------------------------------
Sub Form_Parm_Width( Width )
If Len(Width) > 0 Then
Display " width=" & Width
End If
End Sub
'----------------------------------------------------------------
Sub Anchor_Display( TextToDisplay, HRef )
HTML "<a href=" & Chr(39) & HRef & Chr(39) & ">"
Display TextToDisplay
HTML "</a>"
End Sub
'----------------------------------------------------------------
Sub MenuItem ( TextToDisplay, HRef )
HTML "<ul>"
HTML "<li>"
HTML "<p "
Form_Parm_Align "Left"
Form_Parm_VAlign "Bottom"
HTML ">"
Anchor_Display TextToDisplay, HRef
HTML "</p>"
HTML "</li>"
HTML "</ul>"
End Sub
'----------------------------------------------------------------
Function FormatMoney( Amount )
'
' Standard constants from the MS web site but not built
' into VBScript's default constants.
'
Const TristateTrue = -1
Const TristateFalse = 0
Const TristateUseDefault = -2
'
If IsNull( Amount ) Then
FormatMoney = vbNullString
Else
FormatMoney = FormatCurrency( Amount, 2, TristateTrue _
, False, TristateTrue)
End If
'
End Function
'----------------------------------------------------------------
%>
 |  |  |
 |
There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too.
a $5 tip buys him lunch at McDonalds,
a $20 tip buys his kid Hitoshi a new computer game,
a $39 tip buys his daughter Michiko a few nice outfits.
See our donor list.
|  |
 |  |  |
|
|
|
|