|
Partners
|
|
| Return value | Button Clicked | Return value | Button Clicked |
| 1 | Ok | 5 | Ignore |
| 2 | Cancel | 6 | Yes |
| 3 | Abort | 7 | No |
| 4 | Retry |
This example takes the user back one page if the "Retry" button is pressed:
<script language="VBscript"> returnvalue=MsgBox ("Incorrect",37,"Pop Quiz") If returnvalue=4 Then history.go(-1) End If </script>Considering the importance of flow control statements in virtually anything scripting, let's familiarize ourselves with at least the two most important ones syntax wise for VBScript:
//Basic If statement: If time>0 Then Distant=rate*time End If
//If-else statement: If time>0 Then Distant=rate*time Else distant=0 MsgBox "Invalid time entry" End If
Here's a popular example that uses an if-else statement in conjunction with MsgBox to ask for user confirmation before allowing he/she to enter a page:
<script language="VBscript">
Sub entrance_onClick
returnvalue=MsgBox ("You are about to enter a DHTML intensive site. Proceed?",52,"Greetings!")
If returnvalue=6 Then
window.location="http://www.dynamicdrive.com"
Else
window.location="http://www.yahoo.com"
End If
End Sub
</script>
<form>
<input type="button" name="entrance" value="Click here">
</form>