Presentation is loading. Please wait.

Presentation is loading. Please wait.

Web Development & Design Foundations with XHTML Chapter 14 Key Concepts.

Similar presentations


Presentation on theme: "Web Development & Design Foundations with XHTML Chapter 14 Key Concepts."— Presentation transcript:

1 Web Development & Design Foundations with XHTML Chapter 14 Key Concepts

2 Arithmetic Operators OperatorDescriptionExampleValue of Quantity =assignquantity = 1010 +additionquantity = 10 + 616 -subtractionquantity = 10 - 64 *multiplicationquantity = 10 * 220 /divisionquantity = 10 / 25 2

3 Comparison Operators OperatorDescriptionExampleSample values of quantity that would result in true = =Double equals sign (equivalent) “is exactly equal to” quantity = = 1010 >Greater thanquantity > 1011, 12 (but not 10) > =Greater than or equal to quantity > = 1010, 11, 12 <Less thanquantity < 108, 9 (but not 10) < =Less than or equal to quantity < = 108, 9, 10 ! =Not equal toquantity ! = 108, 9, 11 (but not 10) 3

4 Decision Making if (condition) { … commands to execute if condition is true } else { … commands to execute if condition is false } 4

5 Hands-On Practice 14.6 Pages 552-553 Chapter14/quantityif.html

6 Function A function is a block of one or more JavaScript statements with a specific purpose, which can be run when needed. function function_name() {... JavaScript statements … } 6

7 Using Functions function showAlert() { alert("Please click OK to continue."); } 7 Calling the Function showAlert(); Defining the Function

8 Hands-On Practice 14.7 does not have any default action related to forms. Pages 555-6 Chapter14/quantifyif2.html

9 Form Validation It is common to use JavaScript to validate form information before submitting it to the Web server. ◦ Is the name entered? ◦ Is the e-mail address of correct format? ◦ Is the phone number in the correct format? See Hands-on Practice 14.8 9

10 Validating Form Fields Use the "" or null to check to determine if a form field has information if (document.forms[0].userName.value == "" ) { alert("Name field cannot be empty."); return false; } // end if 10

11 Hands-On Practice 14.8 Pages 558-563 Chapter14/formvalidation.html

12 JavaScript & Accessibility Don’t expect JavaScript to always function for every visitor ◦ Some may have JavaScript disabled ◦ Some may be physically unable to click a mouse Provide a way for your site to be used if JavaScript is not functioning ◦ Plain text links ◦ E-mail contact info 12

13 JavaScript Resources JavaScript Tutorials http://www.w3schools.com/JS http://www.w3schools.com/JS JavaScript Tutorial for the Total Non-Programmer http://www.webteacher.com/javascript/ http://www.webteacher.com/javascript/ More Beginning JavaScript Tutorials http://echoecho.com/javascript.htm http://echoecho.com/javascript.htm Core JavaScript 1.5 Reference Manual http://www.webreference.com/javascript/reference/core_ref http://www.webreference.com/javascript/reference/core_ref Creating Accessible JavaScript http://www.webaim.org/techniques/javascript http://www.webaim.org/techniques/javascript 13


Download ppt "Web Development & Design Foundations with XHTML Chapter 14 Key Concepts."

Similar presentations


Ads by Google