To learn more about author Sanjaya Hettihewa, please visit the author's homepage.
Virtually all VBScript applications interact with users browsing a Web site. Sometimes this interaction is indirect. For example, depending on the time of day, a VBScript application might greet the user with either "Good morning!" or "Good evening!" Although the greeting is displayed on the Web page by a VBScript application, this is not always obvious to the user because the user did not do anything special to execute the VBScript application (other than view it with a Web browser). At other times, the interaction between a VBScript application and the user is very visible and direct--as in the case of an online calculator application.
This chapter demonstrates how to use features of VBScript to directly communicate with the user with the aid of Web-browser objects (HTML form elements, ActiveX controls, and so on) and message boxes. By the end of this chapter, you will be able to create richly interactive Web applications.
There are several ways a VBScript application can obtain user input. Depending on the application and circumstances, you must select one or more of the following methods to obtain user input--these methods will be discussed in detail during the rest of this chapter.
The InputBox function is used to obtain input from the user by presenting a dialog box. The syntax of the InputBox command is as follows:
InputBox(<Prompt>,<Title>,<Default>,<X>,<Y>)
Arguments of the above command that are enclosed in pointed brackets can be replaced with the following values:
The VBScript application in Listing 20.1 demonstrates how the InputBox function is used to obtain user input.
Note: The application in Listing 20.1 can be found in the CD-ROM kit that accompanies this resource library at /Chap-20/InputBox.html. I recommend that you experiment with it before proceeding.
1: <HTML> 2: <HEAD> 3: <TITLE>Using The InputBox Function</TITLE> 4: </HEAD> 5: <BODY BGCOLOR="FFFFFF"> 6: 7: <B> 8: <SCRIPT LANGUAGE="VBScript"> 9: <!-- 10: 11: UserInput = InputBox ("Please enter your name ", _ 12: "The InputBox function is used to obtain user input", _ 13: "Please type your name here", 300, 200) 14: 15: TreeHeight = InputBox ("Please enter the height of your tree", _ 16: "The InputBox function is used to obtain user input", _ 17: "Please type the height of your tree here", 200, 200) 18: 19: document.write "<PRE>" 20: 21: For LoopCountVariable = 0 To (TreeHeight-1) 22: document.write "Hello " & UserInput & "! " 23: For AsterisksCountVariable = 0 To (TreeHeight-LoopCountVariable) 24: document.write " " 25: Next 26: For AsterisksCountVariable = 0 To (LoopCountVariable*2) 27: document.write "*" 28: Next 29: document.write "<BR>" 30: Next 31: 32: For LineCountVariable = 0 To (TreeHeight / 3) 33: For SpaceCountVariable = 0 To ( 7 + Len(UserInput) + (TreeHeight)) 34: document.write " " 35: Next 36: document.write "***<BR>" 37: Next 38: 39: document.write "</PRE>" 40: 41: --> 42: </SCRIPT> 43: </B> 44: 45: </BODY> 46: </HTML>
The application in Listing 20.1 greets the user with his name and draws a tree next
to the greeting (as shown in Figure 20.1). The VBScript application uses the InputBox
function twice: once to obtain the user's name and once to ascertain the height of
the tree.
Lines 19-39 of Listing 20.1 are responsible for greeting the user with the Web
page shown in Figure 20.1. You might want to experiment with the VBScript code in
lines 19-39 to learn how nested loops can be used to perform various repetitive tasks.
Figure 20.1. The VBScript application
greets the user with his name and draws a tree.
When the application in Listing 20.1 is executed, the user is greeted with the
dialog box shown in Figure 20.2. The dialog box in Figure 20.2 is generated by lines
11-13 of the VBScript application in Listing 20.1. Notice how the default value of
the input box (Please type your name here) is displayed and highlighted in the input
box.
Figure 20.2. The VBScript application
asks for the user's name.
The user can type over the default value of the input box as shown in Figure 20.3.
After the user types his name and clicks the OK button, the dialog box shown in Figure
20.4 appears.
Figure 20.3. The user types his name.
The dialog box in Figure 20.4 obtains the height of the tree that will be displayed
on the Web browser. Lines 15-17 of Listing 20.1 are responsible for displaying the
dialog box in Figure 20.4. Again, notice how the default value of the input box (Please
type the height of your tree here) is displayed and highlighted.
Figure 20.4. The VBScript application
asks for the height of the tree.
The user can type over the default value of the input box as shown in Figure 20.5.
After the user types the height of the tree, the VBScript application greets the
user with the Web page shown in Figure 20.1.
Figure 20.5. The user selects a tree
seven lines high.
Data-entry fields of HTML forms can be used by VBScript applications to interact with users. Listing 20.2 demonstrates how the application in Listing 20.1 is implemented using an HTML form for data entry. Use HTML forms for data entry when you are not certain that your users use an ActiveX-enhanced Web browser such as Internet Explorer.
Note: The application in Listing 20.2 can be found in the CD-ROM kit that accompanies this resource library at /Chap-20/HTMLForm.html. I recommend that you experiment with it before proceeding.
1: <HTML> 2: <HEAD> 3: <TITLE>Using HTML Forms For Data Input</TITLE> 4: </HEAD> 5: <BODY BGCOLOR="FFFFFF"> 6: <B> 7: <FORM NAME="UserInput"> 8: <p>Please enter your name 9: <INPUT LANGUAGE="VBScript" TYPE=text 10: VALUE="Please type your name here" SIZE=30 11: NAME="UserName"></p> 12: <p>Please enter the height of the tree 13: <INPUT LANGUAGE="VBScript" TYPE=text VALUE="7" SIZE=5 14: NAME="TreeHeight"></p> 15: 16: <INPUT LANGUAGE="VBScript" TYPE=button VALUE="Please greet me!" 17: ONCLICK="call GreetUser()" NAME="GreetButton"></p> 18: </FORM> 19: 20: <SCRIPT LANGUAGE="VBScript"> 21: <!-- 22: Sub GreetUser 23: 24: document.open 25: document.write "<BODY BGCOLOR=FFFFFF>" 26: 27: Dim UserInput, TreeHeight 28: 29: UserInput = Document.UserInput.UserName.value 30: TreeHeight = Document.UserInput.TreeHeight.value 31: 32: document.write "<PRE>" 33: 34: For LoopCountVariable = 0 To (TreeHeight-1) 35: document.write "Hello " & UserInput & "! " 36: For AsterisksCountVariable = 0 To (TreeHeight-LoopCountVariable) 37: document.write " " 38: Next 39: For AsterisksCountVariable = 0 To (LoopCountVariable*2) 40: document.write "*" 41: Next 42: document.write "<BR>" 43: Next 44: 45: For LineCountVariable = 0 To (TreeHeight / 3) 46: For SpaceCountVariable = 0 To ( 7 + Len(UserInput) + (TreeHeight)) 47: document.write " " 48: Next 49: document.write "***<BR>" 50: Next 51: 52: document.write "</PRE>" 53: document.write "</BODY>" 54: 55: document.close 56: 57: End Sub 58: 59: --> 60: </SCRIPT> 61: </B> 62: </BODY> 63: </HTML>
When the VBScript application in Listing 20.2 is invoked, the Web page in Figure 20.6 is displayed. Notice how the GreetUser subroutine is attached to the OnClick event of GreetButton in lines 16 and 17 of Listing 20.2. When a user clicks the Please greet me! button shown in Figures 20.6 and 20.7, the GreetUser subroutine is executed. The application in Listing 20.2 uses the document.open and document.close functions to display the user greeting when the user clicks the Please greet me! button.
Figure 20.6. The VBScript application in Listing 20.2.
Tip: Notice how each of the data-entry fields of the Web page in Figure 20.6 contains default values. It is a good programming practice to include default data values to guide the user into entering valid data. Default data values also ensure that the application correctly executes even when a user forgets to fill in a data-entry field.
The user may change the default values of the field elements as shown in Figure
20.7. After the user changes the default data-entry field values, the Please greet
me! button is used to view the customized greeting generated by the VBScript application.
Figure 20.7. The default values of the
VBScript application are modified.
The VBScript application greets the user with the Web page shown in Figure 20.8.
The Web page in Figure 20.8 was dynamically generated by lines 22-57 of the VBScript
application in Listing 20.2. Notice how the document.open and document.close functions
are used to change the contents of the Web page without loading a new URL.
Figure 20.8. The VBScript application
greets the user.
The VBScript application in Listing 20.3 demonstrates how ActiveX controls can be used to obtain user input. ActiveX controls provide more control over certain attributes of data-entry fields. Notice how the ActiveX controls with the object IDs UserName and HeightOfTree are defined in Listing 20.3 with attributes such as the font name, background color, and character size.
Note: The application in Listing 20.3 can be found in the CD-ROM kit that accompanies this resource library at /Chap-20/ActiveX.html. I recommend that you experiment with it before proceeding.
Note: The ActiveX application in Listing 20.3 was created using the ActiveX Control Pad. If you are not familiar with the ActiveX Control Pad, refer to Chapter 8, "Developing Web Pages with the ActiveX Control Pad," to learn how the ActiveX Control Pad is used to insert ActiveX controls into Web pages.
The object tag (<Object></Object>) is used in Listing 20.3 to embed ActiveX controls in a Web page. Refer to Chapter 24, "Introduction to ActiveX Controls," to learn more about them.
1: <HTML> 2: <HEAD> 3: <SCRIPT LANGUAGE="VBScript"> 4: <!-- 5: Sub window_onLoad() 6: HeightOfTree.AddItem ("1") 7: HeightOfTree.AddItem ("2") 8: HeightOfTree.AddItem ("3") 9: HeightOfTree.AddItem ("4") 10: HeightOfTree.AddItem ("5") 11: HeightOfTree.AddItem ("6") 12: HeightOfTree.AddItem ("7") 13: HeightOfTree.AddItem ("8") 14: HeightOfTree.AddItem ("9") 15: HeightOfTree.AddItem ("10") 16: HeightOfTree.AddItem ("11") 17: end sub 18: --> 19: </SCRIPT> 20: <TITLE>Using ActiveX Controls For Data Input</TITLE> 21: </HEAD> 22: <BODY BGCOLOR="FFFFFF"> 23: <B> 24: <p>Please enter your name 25: <OBJECT ID="UserName" WIDTH=215 HEIGHT=24 26: CLASSID="CLSID:8BD21D10-EC42-11CE-9E0D-00AA006002F3"> 27: <PARAM NAME="VariousPropertyBits" VALUE="746604571"> 28: <PARAM NAME="BackColor" VALUE="13828080"> 29: <PARAM NAME="Size" VALUE="5680;635"> 30: <PARAM NAME="Value" VALUE="Please type your name here"> 31: <PARAM NAME="FontCharSet" VALUE="0"> 32: <PARAM NAME="FontPitchAndFamily" VALUE="2"> 33: </OBJECT> 34: </p> 35: 36: <p>Please select the height of the tree 37: <OBJECT ID="HeightOfTree" WIDTH=83 HEIGHT=24 38: CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3"> 39: <PARAM NAME="VariousPropertyBits" VALUE="746604571"> 40: <PARAM NAME="BackColor" VALUE="12184829"> 41: <PARAM NAME="DisplayStyle" VALUE="3"> 42: <PARAM NAME="Size" VALUE="2187;635"> 43: <PARAM NAME="MatchEntry" VALUE="1"> 44: <PARAM NAME="ShowDropButtonWhen" VALUE="2"> 45: <PARAM NAME="FontEffects" VALUE="1073741825"> 46: <PARAM NAME="FontHeight" VALUE="200"> 47: <PARAM NAME="FontCharSet" VALUE="0"> 48: <PARAM NAME="FontPitchAndFamily" VALUE="2"> 49: <PARAM NAME="FontWeight" VALUE="700"> 50: </OBJECT> 51: </P> 52: <SCRIPT LANGUAGE="VBScript"> 53: <!-- 54: Sub GreetMeButton_Click() 55: call GreetUser() 56: end sub 57: --> 58: </SCRIPT> 59: <OBJECT ID="GreetMeButton" WIDTH=132 HEIGHT=32 60: CLASSID="CLSID:D7053240-CE69-11CD-A777-00DD01143C57"> 61: <PARAM NAME="Caption" VALUE="Please greet me!"> 62: <PARAM NAME="Size" VALUE="3493;846"> 63: <PARAM NAME="FontEffects" VALUE="1073741825"> 64: <PARAM NAME="FontHeight" VALUE="200"> 65: <PARAM NAME="FontCharSet" VALUE="0"> 66: <PARAM NAME="FontPitchAndFamily" VALUE="2"> 67: <PARAM NAME="ParagraphAlign" VALUE="3"> 68: <PARAM NAME="FontWeight" VALUE="700"> 69: </OBJECT> 70: </B> 71: <SCRIPT LANGUAGE="VBScript"> 72: <!-- 73: Sub GreetUser 74: 75: document.open 76: document.write "<BODY BGCOLOR=FFFFFF>" 77: 78: Dim UserInput, TreeHeight 79: 80: UserInput = UserName.Value 81: TreeHeight = HeightOfTree.Value 82: 83: document.write "<PRE>" 84: 85: For LoopCountVariable = 0 To (TreeHeight-1) 86: document.write "Hello " & UserInput & "! " 87: For AsterisksCountVariable = 0 To (TreeHeight-LoopCountVariable) 88: document.write " " 89: Next 90: For AsterisksCountVariable = 0 To (LoopCountVariable*2) 91: document.write "*" 92: Next 93: document.write "<BR>" 94: Next 95: 96: For LineCountVariable = 0 To (TreeHeight / 3) 97: For SpaceCountVariable = 0 To ( 7 + Len(UserInput) + (TreeHeight)) 98: document.write " " 99: Next 100: document.write "***<BR>" 101: Next 102: 103: document.write "</PRE>" 104: document.write "</BODY>" 105: 106: document.close 107: 108: End Sub 109: 110: --> 111: </SCRIPT> 112: </B> 113: </BODY> 114: </HTML>
As shown in Figure 20.9, the application in Listing 20.3 consists of three ActiveX
controls--a text box, a combo box, and a pushbutton.
Figure 20.9. The ActiveX application
with its default values.
Users can select various values using the ActiveX controls as shown in Figure
20.10. After selecting values, users click the GreetMeButton ActiveX control defined
in lines 59-69 of Listing 20.3.
Figure 20.10. The default values of the
ActiveX application are changed.
The output of the application in Listing 20.3 can be found in Figure 20.11. When
you compare Listing 20.3 with Listing 20.2, you will realize that the main difference
between the two applications is the presence of ActiveX controls in Listing 20.3.
Listing 20.3 uses ActiveX controls instead of HTML-form data-entry controls for data
input.
Figure 20.11. Output of the ActiveX application
in Listing 20.3.
Virtually all VBScript applications display messages to the user. VBScript applications can display messages in the following ways:
Displaying messages by writing to the Web-browser window is very straightforward. All that's required is to use the document.write function. HTML-form elements and ActiveX controls can be used to display messages by using VBScript to set their properties.
Displaying messages using the MsgBox function is a more involved process. The next section demonstrates how the MsgBox function is used to display messages to the user.
A message box can be displayed using the MsgBox command. The syntax of the MsgBox command is as follows:
MsgBox <MessageBoxPrompt>,<ButtonStyle>,<Title>
By replacing <ButtonStyle> with various values shown in Table 20.1, a message box can be customized. For example, an OK dialog box with a warning-message icon can be created by replacing <ButtonStyle> with 48.
Button Type | Button Description |
0 | OK |
1 | OK and Cancel |
2 | Abort, Retry, and Ignore |
3 | Yes, No, and Cancel |
4 | Yes and No |
5 | Retry and Cancel |
16 | Critical Message icon (see Figure 20.16) |
32 | Warning Query icon (see Figure 20.17) |
48 | Warning Message icon (see Figure 20.18) |
64 | Information Message icon (see Figure 20.19) |
256 | Second button is default |
512 | Third button is default |
4096 | Message box always appears on top of all other windows until the user responds to the message box |
Note: The application in Listing 20.4 can be found in the CD-ROM kit that accompanies this resource library at the location /Chap-20/MsgBox.html. I recommend that you experiment with it before proceeding.
1: <!-- 2: © 1996 Sanjaya Hettihewa (http://www.NetInnovation.com/) 3: All Rights Reserved. 4: Permission is hereby given to modify and distribute this code as you wish 5: provided that this block of text remains unchanged. 6: !--> 7: 8: <HTML> 9: 10: <HEAD> 11: <SCRIPT LANGUAGE="VBScript"> 12: <!-- 13: Sub window_onLoad() 14: 15: MessageBoxType.AddItem ("OK message box") 16: MessageBoxType.AddItem ("OK / Cancel message box") 17: MessageBoxType.AddItem ("Abort / Retry / Ignore message box") 18: MessageBoxType.AddItem ("Yes / No / Cancel message box") 19: MessageBoxType.AddItem ("Yes / No message box") 20: MessageBoxType.AddItem ("Retry / Cancel message box") 21: 22: MessageBoxIcon.AddItem ("Critical message icon") 23: MessageBoxIcon.AddItem ("Warning query icon") 24: MessageBoxIcon.AddItem ("Warning message icon") 25: MessageBoxIcon.AddItem ("Information message icon") 26: 27: MessageBoxButtonStatus.AddItem ("First button is default") 28: MessageBoxButtonStatus.AddItem ("Second button is default") 29: MessageBoxButtonStatus.AddItem ("Third button is default") 30: end sub 31: --> 32: </SCRIPT> 33: 34: <TITLE>Using MsgBox For Displaying Data</TITLE> 35: </HEAD> 36: 37: <BODY BGCOLOR="FFFFFF"> 38: <B> 39: <FORM NAME="MsgBoxOptions"> 40: <p>Title of the message box 41: <INPUT TYPE=text VALUE="Title of message box" SIZE=25 NAME="MsgBoxTitle"></p> 42: <p>Message box prompt 43: <INPUT TYPE=text VALUE="Prompt of message box" SIZE=27 NAME="MsgBoxPrompt"></p> 44: <INPUT TYPE=checkbox VALUE="ON" NAME="OnTop"> 45: Message box always appears on top of all other windows until the ¬user responds to the message box 46: </FORM> 47: 48: <p>Please select type of message box 49: <OBJECT ID="MessageBoxType" WIDTH=215 HEIGHT=24 50: CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3"> 51: <PARAM NAME="VariousPropertyBits" VALUE="746604571"> 52: <PARAM NAME="BackColor" VALUE="14022655"> 53: <PARAM NAME="DisplayStyle" VALUE="3"> 54: <PARAM NAME="Size" VALUE="5657;635"> 55: <PARAM NAME="MatchEntry" VALUE="1"> 56: <PARAM NAME="ShowDropButtonWhen" VALUE="2"> 57: <PARAM NAME="FontCharSet" VALUE="0"> 58: <PARAM NAME="FontPitchAndFamily" VALUE="2"> 59: </OBJECT></P> 60: 61: <p>Please select icon of message box 62: <OBJECT ID="MessageBoxIcon" WIDTH=215 HEIGHT=24 63: CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3"> 64: <PARAM NAME="VariousPropertyBits" VALUE="746604571"> 65: <PARAM NAME="BackColor" VALUE="14022655"> 66: <PARAM NAME="DisplayStyle" VALUE="3"> 67: <PARAM NAME="Size" VALUE="5657;635"> 68: <PARAM NAME="MatchEntry" VALUE="1"> 69: <PARAM NAME="ShowDropButtonWhen" VALUE="2"> 70: <PARAM NAME="FontCharSet" VALUE="0"> 71: <PARAM NAME="FontPitchAndFamily" VALUE="2"> 72: </OBJECT></P> 73: 74: <p>Please select the status of buttons 75: <OBJECT ID="MessageBoxButtonStatus" WIDTH=215 HEIGHT=24 76: CLASSID="CLSID:8BD21D30-EC42-11CE-9E0D-00AA006002F3"> 77: <PARAM NAME="VariousPropertyBits" VALUE="746604571"> 78: <PARAM NAME="BackColor" VALUE="14022655"> 79: <PARAM NAME="DisplayStyle" VALUE="3"> 80: <PARAM NAME="Size" VALUE="5657;635"> 81: <PARAM NAME="MatchEntry" VALUE="1"> 82: <PARAM NAME="ShowDropButtonWhen" VALUE="2"> 83: <PARAM NAME="FontCharSet" VALUE="0"> 84: <PARAM NAME="FontPitchAndFamily" VALUE="2"> 85: </OBJECT></P> 86: 87: <p><INPUT TYPE=button VALUE="Please click here to see your message box!" 88: NAME="MsgBoxButton"></p> 89: 90: </B> 91: 92: <SCRIPT LANGUAGE="VBScript"> 93: <!-- 94: Sub MsgBoxButton_OnClick() 95: 96: Dim MessageBoxStyleCode, MessageBoxString, ValidInput 97: 98: MessageBoxStyleCode = 0 99: ValidInput = 1 100: 101: If MsgBoxOptions.OnTop.Checked Then 102: MessageBoxStyleCode = MessageBoxStyleCode + 4096 103: End If 104: 105: Select Case MessageBoxType.Value 106: Case "OK message box" 107: MessageBoxStyleCode = MessageBoxStyleCode + 0 108: Case "OK / Cancel message box" 109: MessageBoxStyleCode = MessageBoxStyleCode + 1 110: Case "Abort / Retry / Ignore message box" 111: MessageBoxStyleCode = MessageBoxStyleCode + 2 112: Case "Yes / No / Cancel message box" 113: MessageBoxStyleCode = MessageBoxStyleCode + 3 114: Case "Yes / No message box" 115: MessageBoxStyleCode = MessageBoxStyleCode + 4 116: Case "Retry / Cancel message box" 117: MessageBoxStyleCode = MessageBoxStyleCode + 5 118: Case Else 119: MsgBox "I'm sorry but you have selected an " & _ 120: "invalid message box type." & _ 121: Chr(10) & "Please select a valid message " & _ 122: "box type using a" & Chr(10) & "pull down " & _ 123: "menu and try again.", 16, "Invalid Input!" 124: ValidInput = 0 125: End Select 126: 127: Select Case MessageBoxIcon.Value 128: Case "Critical message icon" 129: MessageBoxStyleCode = MessageBoxStyleCode + 16 130: Case "Warning query icon" 131: MessageBoxStyleCode = MessageBoxStyleCode + 32 132: Case "Warning message icon" 133: MessageBoxStyleCode = MessageBoxStyleCode + 48 134: Case "Information message icon" 135: MessageBoxStyleCode = MessageBoxStyleCode + 64 136: Case Else 137: MsgBox "I'm sorry but you have selected an invalid " & _ 138: "message box icon." & Chr(10) & "Please " & _ 139: "select a valid message box icon using a" & _ 140: Chr(10) & "pull down menu and try again.", 16, _ 141: "Invalid Input!" 142: ValidInput = 0 143: End Select 144: 145: Select Case MessageBoxButtonStatus.Value 146: Case "First button is default" 147: MessageBoxStyleCode = MessageBoxStyleCode + 0 148: Case "Second button is default" 149: MessageBoxStyleCode = MessageBoxStyleCode + 256 150: Case "Third button is default" 151: MessageBoxStyleCode = MessageBoxStyleCode + 512 152: Case Else 153: MsgBox "I'm sorry but the status of message box " & _ 154: "buttons you selected" & Chr(10) & "is invalid. " & _ 155: "Please select a valid message box button status " & _ 156: "using" & Chr(10) & "a pull down menu and try again.", _ 157: 16, "Invalid Input!" 158: ValidInput = 0 159: End Select 160: 161: If ValidInput Then 162: MessageBoxString = _ 163: "The message box you are about to see is created " & _ 164: "using the following VBScript statement: " & CHR(10) & _ 165: Chr(10) & "MsgBox " & Chr(42) & _ 166: MsgBoxOptions.MsgBoxPrompt.Value & Chr(42) & ", " _ 167: & MessageBoxStyleCode & ", " & _ 168: Chr(42) & MsgBoxOptions.MsgBoxTitle.Value & Chr(42) 169: MsgBox MessageBoxString, 64, "Information" 170: MsgBox MsgBoxOptions.MsgBoxPrompt.Value, _ 171: MessageBoxStyleCode, MsgBoxOptions.MsgBoxTitle.Value 172: End If 173: 174: End Sub 175: --> 176: </SCRIPT> 177: 178: </BODY> 179: </HTML>
The user interface of the application in Listing 20.4 is shown in Figure 20.12;
virtually any type of message box can be created using the data-entry controls in
this figure.
Figure 20.12. The MsgBox application.
Change the values of the data-entry fields as shown in Figure 20.13. Notice how
the pull-down menus are used to select the characteristics of the message box being
created. After specifying these characteristics, click the Please click here to see
your message box! button.
Figure 20.13. Data-entry fields of the
MsgBox application are used to choose the characteristics of a message box.
The Information dialog box in Figure 20.14 appears. This dialog box displays the
actual VBScript statement used to generate a message box with the characteristics
selected in Figure 20.13.
Figure 20.14. The VBScript statement
used to generate the message box selected in Figure 20.13.
After acknowledging the dialog box in Figure 20.14, the application in Listing
20.4 displays a message box with the characteristics selected in Figure 20.13 (as
shown in Figure 20.15).
Figure 20.15. Output of the ActiveX application
in Listing 20.3.
Figures 20.16-20.19 show the types of message boxes that can be created using
the MsgBox function.
Figure 20.16. The Critical Message box.
Figure 20.17. The Warning Query box.
Figure 20.18. The Warning Message box.
Figure 20.19. The Information Message box.
Most Web applications interact with users to obtain and display information, and VBScript provides a rich set of tools for obtaining and displaying information to users. The user-interaction tips and techniques presented in this chapter can be used to develop richly interactive Web applications. VBScript can obtain user input from both HTML form data-entry elements and ActiveX controls. Use ActiveX controls to interact with users when you are certain your users use an ActiveX-enhanced Web browser. ActiveX controls provide additional control over certain attributes of data-entry objects. When interacting with users, you should validate user input before processing it. Refer to Chapter 17, "Data Conversion and Validation," for additional information about validating user input and converting various data types.
© Copyright, Macmillan Computer Publishing. All rights reserved.