![]() Capt. Horatio T.P. Webb | ... the names of things ... & Arrays |
VBSCRIPT VBscript is a "loosely typed" language. The definition of data items (i.e., variables) does NOT have to be done before using the variable in the body of the program. In contrast to languages like C and COBOL where data items have to be defined (declared) before they are used, VBScript allows you to use variables without having to define them first. The "data type' of the variable is determined by the context of its use. The choice of a data name is limited to names that do not exceed 255 characters. They should NOT be any VBscript reserve word or function (like loop, for, while, dim, sqr, log, etc.). They should begin with a letter (A-Z or a-z) and may contain the underscore( _ ) character. Data items are created in VBScript by their usage. All that is required is to assign a value to the name for it to be created (i.e., the data item must appear on the lefty-hand side of the assignment operator (=) ). For example: fred=1
all created variables named fred. These data names may be used to store a variety of different data types. The data types supported by VBScript are:
|
JAVASCRIPT
Javascript is also a "loosely typed" language. The definition of data items (i.e., variables) does NOT have to be done before using the variable in the body of the program. The "data type' of the variable is determined by the context of its use. Variable names must begin with a letter or underscore (i.e, a thru Z, a thru z or _). Following the first character they can contain any letter, number or the underscore. Names cannot contain any punctuation character (e.g., , ( ) ; ' " $ %, etc.) and cannot be any javascript reserved words (e.g., for, Array, new, true, false, if, etc.).
| |||||||||
Data types are defined by their context -- not specific declaractions (i.e., when making a variable assignment, VBScript and Javascript both choose the most appropriate data type for the given values. | ||||||||||
In addition to data items created by the program, there are objects that are used on the HTML page (e.g., radio buttons, cjheck boxes, etc.) that may be referenced by the VBScript code. These "intrinsic" (i.e., built in) HTML objects cannot be referenced by the use of the name= value in the HTML definition. They must be located in their context of the HTML code that is currently in the window. To reference any HTML object in the VBScript code, you can first establish a name for the object by using the SET command. The format is: set name_of_object = object hierarchy In javascript the same definition is applied by using: var name_of_object = object hierarchy; the object hierarchy is defined by the location of the object relative to the current window's contents. The entire browser window is called window. The window contains an HTML document named document, the document may contain one or more forms and the form may contain one or more intrinsic HTML objects (elements). the general format is:
Note that the form (name or number) and the element (name or number) can be used interchangeably. For example, suppose the following HTML page is to be referenced by VBScript code:
<html><body> <form name="formone"> <input type="text" name="T1"><br> <input type="text" name="T2"><br> <input type="text" name="T3"><br> </form> <form name="formtwo"> <input type="text" name="T4"><br> <input type="text" name="T5"><br> <input type="text" name="T6"><br> </form> </body><html> Then the six items' values can be referenced as:
|