Printing a Line with Multiple Statements Using the style attribute, the color of the text is changed from black to magenta. The escape sequence \” places a quote in the string and is not displayed in the browser.">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.

Similar presentations


Presentation on theme: " 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing."— Presentation transcript:

1  2001 Prentice Hall, Inc. All rights reserved. 1 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 Program: Adding Integers 7.4 Memory Concepts 7.5 Arithmetic 7.6 Decision Making: Equality and Relational Operators 7.7 JavaScript Internet and World Wide Web Resources

2  2001 Prentice Hall, Inc. All rights reserved. Outline 2 welcome.html Program Output 1 2 A First Program in JavaScript The document object’s writeln method writes a line of XHTML markup in the XHTML document. The script tag indicates to the browser that the text which follows is part of a script.

3  2001 Prentice Hall, Inc. All rights reserved. Outline 3 Welcome2.html Program Output 1 2 Printing a Line with Multiple Statements Using the style attribute, the color of the text is changed from black to magenta. The escape sequence \” places a quote in the string and is not displayed in the browser.

4  2001 Prentice Hall, Inc. All rights reserved. Outline 4 Welcome3.html Program Output 1 2 Printing Multiple Lines Using break tags, the text is displayed as three lines.

5  2001 Prentice Hall, Inc. All rights reserved. Outline 5 Welcome4.html 1 2 Printing Multiple Lines in a Dialog Box Click Refresh (or Reload) to run this script again The window method alert displays an alert dialog to the user. When the alert dialog displays, the string passed as its one argument is displayed. The escape sequence \n is the newline character that places all remaining text on the next line.

6  2001 Prentice Hall, Inc. All rights reserved. Outline 6 Program Output The OK button allows the user to dismiss (or hide) the dialog. Title bar The dialog is automatically sized to accommodate the string. Mouse cursor

7  2001 Prentice Hall, Inc. All rights reserved Simple Program: Printing a Line of Text in a Web Page

8  2001 Prentice Hall, Inc. All rights reserved. Outline 8 Addition.html 1 2 An Addition Program Click Refresh (or Reload) to run the script again 43 44

10  2001 Prentice Hall, Inc. All rights reserved Another JavaScript Program: Adding Integers When the user clicksOK, the value typed by the user is returned to the program as a string. The program must convert the string to a number. This is the text field in which the user types the value. This is the prompt to the user. This is the default value if the user does not enter a number. Fig. 7.7Prompt dialog displayed by the window object’s prompt method.

11  2001 Prentice Hall, Inc. All rights reserved Memory Concepts Fig. 7.8Memory location showing the name and value of variable number1. Fig. 7.9Memory locations after values for variables number1 and number2 have been input.

12  2001 Prentice Hall, Inc. All rights reserved Arithmetic Fig. 7.10Memory locations after calculating the sum of number1 and number2.

13  2001 Prentice Hall, Inc. All rights reserved Arithmetic

14  2001 Prentice Hall, Inc. All rights reserved Decision Making: Equality and Relational Operators Fig. 7.13Order in which a second-degree polynomial is evaluated.

15  2001 Prentice Hall, Inc. All rights reserved Decision Making: Equality and Relational Operators

16  2001 Prentice Hall, Inc. All rights reserved. Outline 16 Comparison.html 1 2 Performing Comparisons Click Refresh (or Reload) to run the script again Each if statement uses the equality operators to determine the relationship of the two integers input by the user.

18  2001 Prentice Hall, Inc. All rights reserved. Outline 18 Program Output

19  2001 Prentice Hall, Inc. All rights reserved. Outline 19 Program Output

20  2001 Prentice Hall, Inc. All rights reserved. Outline 20 Program Output

21  2001 Prentice Hall, Inc. All rights reserved Decision Making: Equality and Relational Operators


Download ppt " 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing."

Similar presentations


Ads by Google