IMRAN DAUD
FOUNDATION UNIVERSITY
INSTITUTE OF MANAGEMENT AND
COMPUTER SCIENCES
Imran Daud
FUIMCS
Web Engineering
JavaScript
 Java Script can be used in following two different
ways:
 Within html code
 In separate file (file.js)
Html Code and JavaScript
JavaScript file
Datatypes
 Three Core data types
 Integer
 String
 Boolean
 In addition to basic types we have
 Null
 undefined
String
 String can be handled in single or double quotes.
 Example:
Declaring and initializing variables
Dialog Boxes
 Ask question get answers and respond using window
based messages dialog boxes.
 Three methods
 Alert()  alert(String)
 Prompt()  prompt(text, value)
 Confirm()  confirm(message)
Condition and loops
 If – else statement
 Switch
 Loops  for , while, do while
Functions
Function with argument
Associating Function with form field
 Any functionality can be associated with any form
field.
 E.g. <input type="text" id="input" value="" onchange="err()"/>
Objects in Script
Associating Function with Object
Array and Date
Accessing Form Fields
Forms
Example
Example
Reference
 JavaScript By example 2nd Edition by Ellie Quigley

8. java script