Dynamic HTML – Scripting languages
Forms allow the Web page to get input from a user, such as a topic to be searched for, in a keyword search for example. Once the form is complete it can be submitted (sent) to the server for processing. Client side scripting can be used to validate is input prior to sending it to the server.
What is Scripting – When to Use It
Scripting enables you to set and store variables and to work with data in your HTML code. Many Web sites now employ scripting to check which browser a user is running, validate input, work with applets or controls, and communicate to the user.
Instead of running the code on the clients machine it may be run instead on the server using PHP or in Microsofts proprietary environment Active Server Pages (ASP).
Running the code onthe server is known as server side scripting. In this case the server scans the requested web page and runs any script it finds before the page is sent to the browser. After the script is run the resulting web page is then sent to the user. A typical example would be to filter just those records from a database the user has requested.
Below is the corresponding example written using VBScript to illustrate how a piece of VBScript is embedded in the body of an HTML page.
<HTML> <head> <!-- This script runs in response to the user --> <!-- clicking the button --> <SCRIPT LANGUAGE="VBScript" FOR="Btn1" EVENT="OnClick"> MsgBox "Hello from VBScript" </SCRIPT> </HEAD> <BODY> <H3>Running a simple VBScript</H3><HR> <FORM> <INPUT NAME="Btn1" TYPE="BUTTON" VALUE="Click Me"> </FORM> </BODY> </HTML>
Here, because the <SCRIPT> tag specifies the event and the name of the button control, the Sub and End Sub statements normally found in VBScript code are not needed.