Saturday, 27 August 2011

VBScript Part 1: Introduction and Functions and Variable Declarations

Hi All,

VBscript is a programming language specifically used in Internet Explorer browsers. Client side VBScript is only supported by Internet Explorer. It is language developed by Microsoft.

Functions

To create a function, the syntax is as below: 

function main()
    ' comments
    ' coding
end function

Functions is used to perform actions required by the user.

Example of actions are as below:
To display a value returned from the database
To execute SQL statements
To form HTML statements - display check box, text box on the screen
To perform calculations
To return data from the database

Variable Declarations

The declaration of variable using VBScript is as below:

dim a
dim a,b
Assigning Variables
After declaring variables, we can assign values to the variables.

The syntax for assigning variables is as below:

dim a
dim b
a = "First variable"
b = "Second variable"

Differences between VBScript and Javascript

Please note that there are several differences between VBScript and Javascript.

1. The syntax of creating function is different for VBScript and Javascript. 

VBScript

function main

end function

Javascript

function testFunction()
{

}

2. Secondly, in VBScript, we can't assign variables using this method.

VBScript

dim a = "First variable"

Instead, we use this. 

dim a
a = "First variable"

Javascript

var a = "First variable" .

3. Declaration of variables

VBScript
We use the keyword, dim to declare a variable in VBScript. 

Javascript
We are using the keyword var to declare a variable in Javascript.

Saturday, 20 August 2011

Javascript: HTML Events

Hi Everyone,

HTML events can be detected using Javascript. For example, a mouse click or a user selection on a dropdown. We can assign functions to these events and we can attach and detach events as well. Let me further explain the types of events that we use.


onblur: It is triggered when a HTML element has lost focus. For example, you keyed in something in the textbox and then u click outside the textbox. Another example is pressing the tab button on the keyboard.


onchange: An onchange event is triggered when user selects an item from the dropdown. It can be used to handle how a website displays and hides certain fields.


onclick: It is triggered by a mouse click. It is used on radio buttons, buttons or a link on a website.


ondblclick: It is triggered when a mouse button is double clicked


onfocus: It is triggered when a HTML event is being focused.


onkeydown: It is triggered when a key is pressed on the keyboard. It can be used to assist users to enter numeric values only or to avoid users from entering special characters.


onkeyup: It is triggered when a key is lifted up. It is the event after you pressed a key on the keyboard.


onmousedown: It is triggered when a mouse button is pressed


onmouseup: It is triggered when a mouse button is released


That concludes the HTML events for the day.


References:


1. HTML DOM Event Object: http://www.w3schools.com/jsref/dom_obj_event.asp

Cheers,

Rogerkoo