Chapter 7 - JavaScript: Introduction to Scripting

Slides:



Advertisements
Similar presentations
Chapter 7 JavaScript: Introduction to Scripting. Outline Simple Programs Objects and Variables Obtaining User Input with prompt Dialogs – –Dynamic Welcome.
Advertisements

/ 251 Internet Applications Ahmed M. Zeki Sem – / Chapter 8.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
The Web Warrior Guide to Web Design Technologies
Lecture 2 Introduction to C Programming
Introduction to C Programming
 2005 Pearson Education, Inc. All rights reserved Introduction.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C Programming
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Introduction to Scripting.
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Introduction to C Programming
Introduction to scripting
JavaScript: Control Structures September 27, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel,
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Ch 6: JavaScript Introduction to scripting part 2.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
Introduction to Visual Basic Programming. Introduction Simple Program: Printing a Line of Text Another Simple Program: Adding Integers Memory Concepts.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
JavaScript 1 COE 201- Computer Proficiency. Introduction JavaScript scripting language ▫Originally created by Netscape ▫Facilitates disciplined approach.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
 2003 Prentice Hall, Inc. All rights reserved. Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing a Line of Text in a Web Page 7.3 Another JavaScript.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
REEM ALMOTIRI Information Technology Department Majmaah University.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
Chapter 6 JavaScript: Introduction to Scripting
Chapter 2 - Introduction to C Programming
2.5 Another Java Application: Adding Integers
JavaScript: Introduction to Scripting
Chapter 13 - JavaScript/JScript: Introduction to Scripting
Introduction to Scripting
Chapter 2 - Introduction to C Programming
Chapter 7 - JavaScript: Introduction to Scripting
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Advanced Programming Lecture 02: Introduction to C# Apps
JavaScript: Introduction to Scripting
WEB PROGRAMMING JavaScript.
Chapter 2 - Introduction to C Programming
JavaScript: Introduction to Scripting
Chapter 2 - Introduction to C Programming
Chapter 3 – Introduction to C# Programming
JavaScript: Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
Chapter 2 - Introduction to C Programming
JavaScript: Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
JavaScript: Introduction to Scripting
Presentation transcript:

Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing a Line of Text in a Web Page 7.3 Obtaining User Input with prompt Dialogs 7.3.1 Dynamic Welcome Page 7.3.2 Adding Integers 7.4 Memory Concepts 7.5 Arithmetic 7.6 Decision Making: Equality and Relational Operators 7.7 Web Resources

In this lesson, you will learn: Objectives In this lesson, you will learn: To be able to write simple JavaScript programs. To be able to use input and output statements. To understand basic memory concepts. To be able to use arithmetic operators. To understand the precedence of arithmetic operators. To be able to write decision-making statements. To be able to use relational and equality operators.

JavaScript scripting language 7.1  Introduction JavaScript scripting language Enhances functionality and appearance Client-side scripting Makes pages more dynamic and interactive Foundation for complex server-side scripting Program development Program control

7.2 Simple Program: Printing a Line of Text in a Web Page Inline scripting Written in the <body> of a document <script> tag Indicate that the text is part of a script type attribute Specifies the type of file and the scripting language use writeln method Write a line in the document Escape character ( \ ) Indicates “special” character is used in the string alert method Dialog box

welcome.html (1 of 1)

welcome2.html (1 of 1)

welcome3.html 1 of 1

welcome4.html 1 of 1

7.2 Simple Program: Printing a Line of Text in a Web Page

7.3.1  Dynamic Welcome Page A script can adapt the content based on input from the user or other variables

welcome5.html (1 of 2)

welcome5.html (2 of 2)

7.3.1  Dynamic Welcome Page When the user clicks OK, the value typed by the user is returned to the program as a string. This is the prompt to the user. This is the default value that appears when the dialog opens. This is the text field in which the user types the value. Fig. 7.7 Prompt dialog displayed by the window object’s prompt method.

Prompt user for two integers and calculate the sum (Fig. 7.8) 7.3.2 Adding Integers Prompt user for two integers and calculate the sum (Fig. 7.8) NaN (not a number) parseInt Converts its string argument to an integer

Addition.html (1 of 2)

Addition.html (2 of 2)

Variable names correspond to locations in the computer’s memory 7.4  Memory Concepts Variable names correspond to locations in the computer’s memory Every variable has a name, a type, and a value Read value from a memory location nondestructive

number1 45 7.4 Memory Concepts Fig. 7.9 Memory location showing the name and value of variable number1.

number1 45 number2 72 7.4 Memory Concepts Fig. 7.10 Memory locations after values for variables number1 and number2 have been input.

number1 45 number2 72 sum 117 7.4 Memory Concepts Fig. 7.11 Memory locations after calculating the sum of number1 and number2.

Many scripts perform arithmetic calculations Expressions in JavaScript must be written in straight-line form

7.5  Arithmetic

7.5 Arithmetic Step 1. y = 2 * 5 * 5 + 3 * 5 + 7; 2 * 5 is 10 (Leftmost multiplication) Step 2. y = 10 * 5 + 3 * 5 + 7; 10 * 5 is 50 (Leftmost multiplication) Step 3. y = 50 + 3 * 5 + 7; 3 * 5 is 15 (Multiplication before addition) Step 4. y = 50 + 15 + 7; 50 + 15 is 65 (Leftmost addition) Step 5. y = 65 + 7; 65 + 7 is 72 (Last addition) Step 6. y = 72; (Last operation—place 72 into y ) Fig. 7.14 Order in which a second-degree polynomial is evaluated.

7.6 Decision Making: Equality and Relational Operators Decision based on the truth or falsity of a condition Equality operators Relational operators

7.6 Decision Making: Equality and Relational Operators  £

welcome6.html (1 of 3)

welcome6.html (2 of 3)

welcome6.html (3 of 3)

7.6 Decision Making: Equality and Relational Operators