- validating user input to text boxes in on-screen forms

ugliestharrasSoftware and s/w Development

Nov 4, 2013 (4 years and 8 months ago)



is a client
side scripting language.

Programs run in the web browser on the client's computer.

(PHP, in contrast, is a server
side scripting language.

.. programs run on the web server computer)

A program in the client's browser can do various useful tasks:


validating user input to text boxes in on
screen forms


modifying parts of the web page, e.g. in response to user actions (DHTML)


fetching data items from the server, as a background task (AJAX)

Doing work on the client computer can speed
up Web Database Applications

.. avoids data transfer delays and server workload delay.

We need to know about JavaScript in order to use the Google Maps API

.. and also to use AJAX.

JavaScript programs are included in web pages

.. in two alternative ways:

1. As program code inside a <script> .. </script> element (between these two tags).

2. As a separate .JS program that is included as the page loads.

<< examples of the two uses for script tags >>

An HTML document has a <head>..</head> section and a <body> .. </body> section.


the body section contains the inforamtion displayed on screen


the head contains various definitions.

JavaScript can be embedded in the head or the body of a web page

.. but behaves differently in each case:

Code in the body section is executed immediately, as the program loads

Code in the head is a collection of function definitions, to be called later

.. e.g. when particular events occur.

<< examples of head and body code >>

JavaScript can be used to respond to events

<< examples of onClick and other events >>


<h3><font color='brown' id='hello'>




HTML tags can have IDs:

This allows JavaScript to change parts of the web page:

<input type='button' value='make Hello blue' onClick='JavaScript:

document.getElementById("hello").color="blue" ' >

As well as reading properties of the tag

.. Including properties such as the position and area occupied by the tag’s object on
the web page on screen.