Tutorial 11 Working with Operators and Expressions

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

Java Script Session1 INTRODUCTION.
HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
1 HCI 201 JavaScript - Part 1. 2 Static web pages l Static pages: what we have worked with so far l HTML tags tell the browser what to do with the content.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Tutorial 16 Working with Dynamic Content and Styles.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Tutorial 15 Working with the Event Model. XP Objectives Compare the IE and W3C event models Study how events propagate under both event models Write a.
Tutorial 10 Programming with JavaScript
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Tutorial 14 Working with Forms and Regular Expressions.
ASP.NET Programming with C# and SQL Server First Edition
JavaScript, Third Edition
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
JavaScript Events and Event Handlers 1 An event is an action that occurs within a Web browser or Web document. An event handler is a statement that tells.
XP Tutorial 14 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
Tutorial 14 Working with Forms and Regular Expressions.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
The Web Wizard’s Guide To JavaScript Chapter 6 Working with Dates and Times.
Creating an Animated Web Page
XP Tutorial 4 New Perspectives on JavaScript, Comprehensive1 Working with Objects Creating an Animated Web Page.
2440: 211 Interactive Web Programming Expressions & Operators.
Chapter 3: Data Types and Operators JavaScript - Introductory.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
Tutorial 8 Programming with ActionScript 3.0. XP Objectives Review the basics of ActionScript programming Compare ActionScript 2.0 and ActionScript 3.0.
Using Client-Side Scripts to Enhance Web Applications 1.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
XP Tutorial 16 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
การสคริปท์ฝั่งลูกข่ายด้วย JavaScript การเขียนโปรแกรมเว็บ.
XP Tutorial 8 Adding Interactivity with ActionScript.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 2 New Perspectives on JavaScript, Comprehensive1 Working with Operators and Expressions Creating a New Year’s Day Countdown Clock.
Module 5 JavaScript Operators. CS346 Javascript-52 Examples  JS-5 Examples.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Chapter 14 JavaScript: Part II The Web Warrior Guide to Web Design Technologies.
XP Tutorial 7 New Perspectives on JavaScript, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
Tutorial 11 1 JavaScript Operators and Expressions.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
JavaScript Tutorial. What is JavaScript JavaScript is the programming language of HTML and the Web Programming makes computers do what you want them to.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
PHP using MySQL Database for Web Development (part II)
Programming Web Pages with JavaScript
Tutorial 10 Programming with JavaScript
JavaScript is a programming language designed for Web pages.
SEEM4570 Tutorial 05: JavaScript as OOP
Introduction to Scripting
JavaScript and Ajax (Expression and Operators)
Objectives Insert a script element Write JavaScript comments
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
Tutorial 10 Programming with JavaScript
JavaScript Basics What is JavaScript?
JavaScript: Introduction to Scripting
The Web Wizard’s Guide To JavaScript
Web Programming and Design
Presentation transcript:

Tutorial 11 Working with Operators and Expressions

Objectives Work with event handlers Insert a value into a Web form field Create and work with date objects Extract information from date objects Work with arithmetic, unary, conditional, and logical operators Understand the properties and methods of the Math object Understand how JavaScript works with numeric values Run time-delayed and timed-interval commands New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Introducing onevent Processing An event is an action that occurs within a Web browser or Web document. An event handler is a statement that tells browsers what code to run in response to the specified event. Script New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Introducing onevent Processing New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Introducing onevent Processing To insert an event handler as an element attribute, use the syntax <element onevent = "script"> ... where element is the Web page element, event is the name of an event associated with the element, and script is a command to be run in response to the event New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with Date Objects Date objects contain information about a specified date and time To store a date and time in a variable, use the JavaScript command variable = new Date("month day, year hours:minutes:seconds") where variable is the name of the variable that contains the date object, and month, day, year, hours, minutes, and seconds indicate the date and time to be stored in the object. Time values are entered in 24-hour time New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with Date Objects To store a date and time using numeric values, use the JavaScript command variable = new Date(year, month, day, hours, minutes, seconds) where year, month, day, hours, minutes, and seconds are the values of the date and time, and the month value is an integer from 0 to 11, where 0 = January, 1 = February, and so forth. Time values are entered in 24-hour time. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with Date Objects To create a date object containing the current date and time, use the following JavaScript command: variable = new Date() New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with Date Objects Date methods can be used to retrieve information from a date object or to change a date object’s value New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with Date Objects New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with Operators and Operands An operator is a symbol used to act upon an item or a variable within a JavaScript expression. The variables or expressions that operators act upon are called operands. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with Operators and Operands Binary operators work with two operands in an expression. Unary operators work with one operand. Increment operators increase the value of the operand by 1. x++; Decrement operators decrease the value of the operand by 1. x--; New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with Operators and Operands Assignment operators assign values to items. Equal sign (=) x = x + y A common use of the += operator is to concatenate strings or add a value to an existing value of a variable New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with Operators and Operands New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with the Math Object and Math Methods The Math object is an object that can be used for performing mathematical tasks and storing mathematical values. Math methods store functions used for performing advanced calculations and mathematical operations such as: Generating random numbers Extracting square roots Calculating trigonometric values New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with the Math Object and Math Methods New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with the Math Object and Math Methods The Math object also stores numeric values for mathematical constants. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Controlling How JavaScript Works with Numeric Values Some mathematical operations can return results that are not numeric values. You cannot divide a number by a text string Returns “NaN” You cannot divide a number by zero Returns “Infinity” The isNaN function is a Boolean function that tests a value to see whether it is numeric or not. The isFinite function is a Boolean function that checks for the value of Infinity. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Controlling How JavaScript Works with Numeric Values New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with Conditional, Comparison, and Logical Operators A conditional operator is a ternary operator that tests whether a certain condition is true or not. A comparison operator is an operator that compares the value of one expression to another. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with Conditional, Comparison, and Logical Operators Logical operators allow you to connect several expressions New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Running Timed Commands A time-delayed command is a JavaScript command that is run after a specified amount of time has passed. setTimeout(“command”, delay); clearTimeout(); A time-interval command instructs the browser to run the same command repeatedly at specified intervals. setInterval (“command”, interval); clearInterval(); New Perspectives on HTML, XHTML, and Dynamic HTML, 4e