Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2000 – All Rights Reserved - Page 1 Introduction to JavaScript Programming Part Two.

Similar presentations


Presentation on theme: "© 2000 – All Rights Reserved - Page 1 Introduction to JavaScript Programming Part Two."— Presentation transcript:

1 © 2000 – All Rights Reserved - Page 1 Introduction to JavaScript Programming Part Two

2 © 2000 – All Rights Reserved - Page 2 Today’s Topics Objects, Properties, and Methods Conditionals Functions JavaScript Source Files Events and Event Handlers Frames and Arrays

3 © 2000 – All Rights Reserved - Page 3 Tags, Attributes, Values Tag is a markup instruction surrounded by signs Attributes are characteristics of a Tag Values are assigned to Attributes Figure I-1, Page I.3

4 © 2000 – All Rights Reserved - Page 4 Objects, Properties, & Values Objects, Properties, & Values An object is a real-world entity –carl An object is described by properties Properties differentiate among objects –carl.build Properties are assigned values –carl.build = “sturdy” object.property = “value”

5 © 2000 – All Rights Reserved - Page 5 Objects, Methods, & Arguments Objects, Methods, & Arguments A method is a behavior you want an object to perform –carl.eatless An argument is a value given to the method –carl.eatless(“bacon”) –carl.eatmore(“chicken”) object.method(“argument”)

6 © 2000 – All Rights Reserved - Page 6 Object Hierarchy (partial) Some objects can be properties of another object, for instance… A document is an object on its own, but A document might be a property of a window

7 © 2000 – All Rights Reserved - Page 7 Conditionals Conditionals Useful for validating form data Compare data to a desired value Two possible outcomes: True or False The If statements The While statement

8 © 2000 – All Rights Reserved - Page 8 Conditional Examples

9 © 2000 – All Rights Reserved - Page 9 If Statements If Statements Decision making a.k.a. flow control Execute specific programming if a conditional expression returns “True” if (conditional expression) { statement(s); }

10 © 2000 – All Rights Reserved - Page 10 If…Else Statements If…Else Statements Execute alternate programming if a conditional expression returns “False” if (conditional expression) { statement(s); } else { statement(s); }

11 © 2000 – All Rights Reserved - Page 11 While Loop While Loop Code which is to execute repeatedly while or as long as a condition exists While (conditional expression) { statement(s); }

12 © 2000 – All Rights Reserved - Page 12 While Loop Example While Loop Example var count = 1; while (count <= 5) { document.writeln(count); ++count; } document.writeln(“All finished.”); 1 2 3 4 5 All finished.

13 © 2000 – All Rights Reserved - Page 13 FunctionsFunctions Individual programming statements often grouped into “procedures” In JavaScript procedures are called functions Defining functions Calling functions

14 © 2000 – All Rights Reserved - Page 14 JavaScript Source Files JavaScript Source Files An external file ending in *.js Contains no HTML Contains only JavaScript Easy repetitive use of longer code Can be shared among multiple HTML pages

15 © 2000 – All Rights Reserved - Page 15 Events Events An event is an action occurring on a web page, usually by the user –A mouse passing over a button –A user clicking a hyperlink –An insertion point (blinking cursor) in a form textbox –Clicking Stop on the browser’s icon bar

16 © 2000 – All Rights Reserved - Page 16 Event Handlers Triggering events are actions associated with event handlers

17 © 2000 – All Rights Reserved - Page 17 FormsForms Many forms use CGI (Common Gateway Interface) programs written in Perl for server-side data processing Other forms simply send the results to an email address JavaScript and Event Handlers enable useful processes based on the contents of forms or the events occurring on forms

18 © 2000 – All Rights Reserved - Page 18 HTML’s Tag TYPE button checkbox file hidden image password radio reset submit text onblur=“script” onchange=“script” onclick=“script” ondblclick=“script” onfocus=“script” onkeydown=“script” onkeyup=“script” onselect=“script” etc.

19 © 2000 – All Rights Reserved - Page 19 Frames and JavaScript Frames allow browser windows to be split into smaller units In JavaScript, each frame is an object Therefore, JavaScript can apply properties and methods to each frame

20 © 2000 – All Rights Reserved - Page 20 Arrays Arrays An array contains a set of data represented by a single variable name An array is a JavaScript object Define one more element than you need Leave element [0] empty

21 © 2000 – All Rights Reserved - Page 21 Test Your Knowledge Test Your Knowledge Page I.17 True/False Questions 6-10 Multiple Choice Questions 7-10

22 © 2000 – All Rights Reserved - Page 22 Introduction to JavaScript Programming Part Two


Download ppt "© 2000 – All Rights Reserved - Page 1 Introduction to JavaScript Programming Part Two."

Similar presentations


Ads by Google