DHTML Lab: JavaScript Enhancement with VBScript | 7 | WebReference

DHTML Lab: JavaScript Enhancement with VBScript | 7

Logo

JavaScript Enhancement with VBScript
the not-so-droll VBScript pop-ups, 1/2


VBScript has its own dialogs, similar to those of JavaScript, but with the option of customization.

The Message Box Dialog

The Message Box dialog is created using the VBScript MsgBox() function:
MsgBox(prompt,buttons,title)

where:



MsgBox(
"My Message Box Title",
4,
"My Message Box Message")
(4 + 0 + 0 + 0)


MsgBox(
"DHTML Lab",
292,
"Proceed?")

(4 + 32 + 256 + 0)


MsgBox("YIKES!",
21,
"FATAL!\nSystem\nCrash\nComing!")
(5 + 16 + 0 + 0)

Values for the buttons Argument

ValueDisplayDescriptionReturn Values
0OK button displayed only1 - OK
1OK and Cancel buttons displayed1 - OK; 2 - Cancel
2Abort, Retry and Ignore buttons displayed3 - Abort; 4 - Retry; 5 - Ignore
3Yes, No and Cancel buttons displayed6 - Yes; 7 - No; 2 - Cancel
4Yes and No buttons displayed6 - Yes; 7 - No
5Retry and Cancel buttons displayed4 - Retry; 2 - Cancel
0 No icon displayed
16Critical icon displayed
32Query icon displayed
48Exclamation icon displayed
64Information icon displayed
0First button is default
256Second button is default
512Third button is default
0 Application Modal. Present application (browser) is suspended until user responds.
4096 System Modal. All applications (windows) are suspended until user responds.

As you can see, there are four groups of values. To achieve the dialog "look" for our application, we must take one value from each group and add them together. The resulting sum becomes our buttons argument.

Refer to the examples in the left column. Compare the buttons argument value and the resulting dialog to the table above.

Return Values

Button
Pressed
Return
Value
OK1
Cancel2
Abort3
Retry4
Ignore5
Yes6
No7

The MsgBox() function returns an integer value that identifies which button was clicked by the user. The table on the left lists the return values associated with the seven available buttons. The table above lists the possible return values for each button group. We'll be discussing the use of return values later.

It is apparent that the MsgBox() function can be used for better looking Alert and Confirm dialogs. But what about Prompt dialogs?


Produced by Peter Belesis and

All Rights Reserved. Legal Notices.
Created: Nov. 18, 1998
Revised: Nov. 18, 1998

URL: http://www.webreference.com/dhtml/column22/js-vbMsgBox.html