you can employ the script element to add vbscript


You can employ the SCRIPT element to add VBScript code to an HTML page.

The SCRIPT Tag

VBScript code is written inside paired SCRIPT tags.

For instance, a process to test a delivery date might appear as follows:

SCRIPT LANGUAGE="VBScript"

Function CanDeliver(Dt)

CanDeliver = (CDate(Dt) - Now()) > 2

End Function

SCRIPT

Beginning & ending SCRIPT tags surround the code. The LANGUAGE attribute specified the scripting language. You have to specify the language since browsers can use other scripting languages, like JavaScript. Notice that the CanDeliver function is embedded in comment tags. This prevents browsers which do not support the SCRIPT tag from displaying the code on the page.

As the example is a general function - it is not tied to any specific form control - you can comprise it in the HEAD section of the page as shown below:

 

Function CanDeliver(Dt)

CanDeliver = (CDate(Dt) - Now()) > 2

End Function

You can employ SCRIPT blocks anywhere in an HTML page. You can put them in the BODY and HEAD both sections. Though, you will probably desire to put all general-purpose scripting code in the HEAD section to keep all the code together. Keeping your code in the HEAD section make sure that all the code is read & decoded before it is required by any calls from inside the BODY section.

One distinguished exception to this rule is that you may want to provide inline scripting code within forms to respond to the events of objects in your form. For instance, you can embed scripting code to respond to a button click in a form as shown in Figure:

HTML

HEAD

TITLE Test Button EventsTITLE

HEAD

BODY

FORM NAME="Form1"

INPUT TYPE="Button" NAME="Button1" VALUE="Click"

SCRIPT FOR="Button1" EVENT="onClick" LANGUAGE="VBScript"

MsgBox "Button Pressed!"

This coding example will display a button on Web Page. While you click on the button it would display a message box stating "Button Pressed".

Mostly code will appear in either Sub or Function process and will be called only while the code you have written causes that function to execute. Though, you can write VBScript code outside process, but still in a SCRIPT block. This code is executed only once, while the HTML page loads. This let you to initialize data or dynamically alter the look of your Web page when it loads.

Request for Solution File

Ask an Expert for Answer!!
Visual Basic Programming: you can employ the script element to add vbscript
Reference No:- TGS0415396

Expected delivery within 24 Hours