What is scripting language? first defination- a language which can be used to enhance routines of an operating system shell script, bash script, perl second defination - a language which is not a proper language, it is subset of a programming language, used for a specific purpose only javascript,vbscript,jscript in case of javascript ,we use second defination only Why we need to learn client side scripting a server has to server request of numerous clients, for which it uses its resources such as ram,processor,hdd etc. a client side script may help to reduce load on server. by doing some processings at client side if possible, by using resources of client such as ram,processor, hdd we can classify work done by javascript in 5 categories 1. client side validation data at client side can be validated for a. pattern ascii values regex b. range if only valid data is passed to server server load is reduced 2. client side calculation used in shopping carts all shopping cart calculations can be done using javascript, only checkouts (payment) are validated by server side script 3. dhtml Dynamic HTML it is not generating dynamic web content it is just dynamic presentation of web content slide shows menu popup news tickers it is combination of html+css+javascript 4. browser properties usage identifying web browser resolution identification adding a page to bookmarks/favourites set a page as homepage(client side) cookies can also be managed using javascript 5. ajax ==================================================== Javascript code is embeded within html page or or Why we learn javascript only and not other client side scripting languages javascript started by netscape navigator now maintained by sun-oracle w3c conformance rule for standard web browsers to support it i.e. all browsers do support it syntaxes resemble c programming jscript started and maintained by Microsoft no such rule,only IE supports it syntaxes resemble c programming vbscript started and maintained by Microsoft no such rule,only IE supports it syntaxes resemble vb programming ===================================================== output statement document.write(""); concatenation operator is + when atleast one operand is non numeric if both operands are numeric, it would be addition s="1"; r="1"; t=s+r; t="11" dialog box 1. alert is used to deliver critical message user cant continue to browse, without reading ths message it has only single button, ok alert("Message"); 2. confirm it is used for boolean input Sy:-confirm (" Message"); it has two buttons ok true cancel false 3. prompt is used for string input it can also be used for numeric input prompt("Message","default value"); ======================================================== syntax for defining a function in javascript function is a keyword function function_name([parameters]) { [return] } as javascript is loosely typed, data types are not specified function add(x,y) { return x+y; } ======================================================== universe.milkyway.solarsystem.earth.asia.india.mp.bhopal.indrapuri.sectorc.plot275.class5 document object model to fetch html form data in javascript by name attribute x=document.all.formname.fieldname.value; to assign value by name attribute document.all.formname.fieldname.value=n by id attribute x=document.getElementById('id').value; to assign document.getElementById('id').value=n; ---------------------------------------------------------------------------- JavaScript Display Possibilities JavaScript can "display" data in different ways: Writing into an alert box, using window.alert(). Writing into the HTML output using document.write(). Writing into an HTML element, using innerHTML. Writing into the browser console, using console.log().