Download presentation
Presentation is loading. Please wait.
Published byKory Wells Modified over 9 years ago
1
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris
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
Copyright © Terry Felke-Morris DECISION MAKING if (condition) { … commands to execute if condition is true } else { … commands to execute if condition is false } 4
5
Copyright © Terry Felke-Morris HANDS-ON PRACTICE 14.6 Page 561 chapter14/quantityif.html 5
6
Copyright © Terry Felke-Morris 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
Copyright © Terry Felke-Morris USING FUNCTIONS function showAlert() { alert("Please click OK to continue."); } 7 Calling the Function showAlert(); Defining the Function
8
Copyright © Terry Felke-Morris HANDS-ON PRACTICE 14.7 Page 564 chapter14/quantityif2.html 8
9
Copyright © Terry Felke-Morris 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 9
10
Copyright © Terry Felke-Morris 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 10
11
Copyright © Terry Felke-Morris HANDS-ON PRACTICE 14.8 Page 567 chapter14/formvalidation.html 11
12
Copyright © Terry Felke-Morris 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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.