Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 1.

Slides:



Advertisements
Similar presentations
Microsoft® Small Basic
Advertisements

Murach’s JavaScript, C3© 2009, Mike Murach & Associates, Inc.Slide 1.
Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc. Slide 1.
Murach’s JavaScript, C1© 2009, Mike Murach & Associates, Inc. Slide 1.
Slide 1 MIS3023 Professor: Akhilesh Bajaj The University of Tulsa.
 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
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Computer Science 1620 Loops.
Murach’s JavaScript, C5© 2009, Mike Murach & Associates, Inc.Slide 1.
1 CSI 101 Elements of Computing Fall 2009 Lecture #4 Using Flowcharts Monday February 2nd, 2009.
Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 1.
Murach’s JavaScript, C13© 2009, Mike Murach & Associates, Inc.Slide 1.
Murach’s JavaScript, C1© 2009, Mike Murach & Associates, Inc.Slide 1.
Repeating Program Instructions Chapter Microsoft Visual Basic.NET: Reloaded 1.
1 Lab Session-III CSIT-120 Spring 2001 Revising Previous session Data input and output While loop Exercise Limits and Bounds GOTO SLIDE 13 Lab session.
Murach's C# 2012, C7© 2013, Mike Murach & Associates, Inc.Slide 1.
Advanced Decisions and Loops Chapter Some Simple Schoolroom Statistics.
JavaScript Form Validation
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Java Programming Constructs 1 MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
THE BIG PICTURE. How does JavaScript interact with the browser?
© 2012, Mike Murach & Associates, Inc.
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Writing JavaScript Functions. Goals By the end of this unit, you should understand … How to breakdown applications into individual, re-usable modules.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
JavaScript, Fourth Edition
IS2802 Introduction to Multimedia Applications for Business Lecture 3: JavaScript and Functions Rob Gleasure
Agenda Perform Quiz #1 (20 minutes) Loops –Introduction / Purpose –while loops Structure / Examples involving a while loop –do/while loops Structure /
Functions.  Assignment #2 is now due on Wednesday, Nov 25 th  (No Quiz)  Go over the midterm  Backtrack and re-cover the question about tracing the.
Chapter 2 Murach's JavaScript and jQuery, C2© 2012, Mike Murach & Associates, Inc.Slide 1.
Project Two Adding Scrolling Messages! Page 2.4 to 2.18 Today’s Agenda Look at scrolling message coding. Create a web page with a text box. Create a web.
Event Handling (the right way). A Simple Web Page Events - Summary The web page looks like this:
Chapter 4 Murach's JavaScript and jQuery, C4© 2012, Mike Murach & Associates, Inc.Slide 1.
Chapter 6 Murach's JavaScript and jQuery, C6© 2012, Mike Murach & Associates, Inc.Slide 1.
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 1.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
Chapter 5 Murach's JavaScript and jQuery, C1© 2012, Mike Murach & Associates, Inc.Slide 1.
CGS 3066: Web Programming and Design Spring 2016 PHP.
Learning Javascript From Mr Saem
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
Murach's ASP.NET 4.5/C#, C3© 2013, Mike Murach & Associates, Inc.Slide 1.
CSS Colors, JavaScript Variables, Conditionals and Basic Methods
>> Introduction to JavaScript
© 2009, Mike Murach & Associates, Inc.
© 2015, Mike Murach & Associates, Inc.
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
Introduction to JavaScript
JavaScript, continued.
© 2010, Mike Murach & Associates, Inc.
The relational operators
CSS Colors, JavaScript Variables, Conditionals and Basic Methods
Event Driven Programming & User Defined Functions
© Akhilesh Bajaj, All rights reserved.
In Class Program: Today in History
T. Jumana Abu Shmais – AOU - Riyadh
Functions, Regular expressions and Events
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT
Web Design and Development
Introduction to JavaScript
Murach's JavaScript and jQuery (3rd Ed.)
Web Programming and Design
Web Programming and Design
Web Programming and Design
Murach's JavaScript and jQuery (3rd Ed.)
Murach's JavaScript and jQuery (3rd Ed.)
Presentation transcript:

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 1

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 2

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 3

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 4

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 5

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 6

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 7

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 8

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 9

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 10

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 11

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 12

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 13

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 14

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 15

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 16

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 17

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 18

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 19

Slide 20 Variables versus Objects in JavaScript -Variable names refer to one fixed memory location. They cannot change memory addresses. -Object names contain a memory address that is changeable. They can be used to point to object blobs. -Both variables and objects have methods that we can call. -Object blobs need to be created using the new keyword. -If an object blob has no object name pointing to it, then it’s memory address has been lost and it is garbage. This is automatically collected. See TestVariableAssignments.html.

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 21

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 22

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 23

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 24

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 25

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 26

Slide 27 var date1 = new Date(); date1.setFullYear(2011, 6, 1); // , ok // set date2 the same date as date1 var date2 = date1; // now I'm gonna set a new date for date2 date2.setFullYear(2011, 9, 8); alert("Date2 is "+ (date2.getMonth()+1) + "-" + date2.getDate() + "-" + date2.getFullYear()); alert("Date1 is " + date1.getMonth()+1) + "-" + date1.getDate() + "-" + date1.getFullYear()); // , ok //Now inspect value of date1 // , expecting // I didn't assign a new date to date1 // WHY is date1 changed?

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 28

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 29

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 30 One common programming error Confusing the assignment operator ( = ) with the equality operator ( ==).

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 31

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 32

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 33

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc. Slide 34 Fun In Class Assignment for if Write a javascript based program, called ComputeTotalSalary.java for our sales force. The program should have 1 html file, 1 css file and 1 js file. It should ask the user to input the name of the salesperson (String), the base salary and the total sales of last year (check they Are both numbers). If the sales are below zero, the program should print an error and exit. If the sales are between $1 and $25,000, the program should add a bonus of 5% of the sales to the base. If the sales are between $25,000 and $50,000, the program should add a bonus of 10% of sales. If the sales are between $50,000 and $100,000 it should add a bonus of 15% of sales. Sales over $100,000 merit a 20% of-sales bonus. Finally, the program should print the statement: The final salary of is $XXXX.XX and exit.

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 35

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 36

Slide 37 var calculate_click = function () { do { $("salesTax").value = ""; $("total").value = ""; do { var subtotal = parseFloat(prompt("Please enter the subTotal as a number") ); if(isNaN(subtotal) || subtotal < 0 ) alert("Subtotal must be a number that is zero or more!"); } while(isNaN(subtotal) || subtotal < 0 ); do { var taxRate = parseFloat( prompt("Please enter the taxRate as a percentage number") ); if( isNaN(taxRate) || taxRate < 0 ) alert("Tax Rate must be a number that is zero or more!"); } while( isNaN(taxRate) || taxRate < 0 ); for(var shippingCharges = parseFloat( prompt("Please enter the shipping Charges as a number")); (isNaN(shippingCharges) || shippingCharges < 0 ); alert("Shipping Charges must be a number that is zero or more!"), shippingCharges = parseFloat( prompt("Please enter the shipping Charges as a number")) ); var salesTax = subtotal * (taxRate / 100); salesTax = parseFloat( salesTax.toFixed(2) ); var total = subtotal + salesTax + shippingCharges; $("salesTax").value = salesTax; $("total").value = "$"+total.toFixed(2); var response = confirm("Run again? "); //alert("The value of response is" + response); } while(response);//end do-while $("salesTax").value = ""; $("total").value = ""; }//calculaet_click

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc. Slide 38 Fun In Class Assignment for while and for Recall the javascript based program, called ComputeTotalSalary.java for our sales force. The program has 1 html file, 1 css file and 1 js file. It should ask the user to input the name of the salesperson (String), the base salary and the total sales of last year (check they are both numbers). If the sales are below zero, the program should print an error and exit. If the sales are between $1 and $25,000, the program should add a bonus of 5% of the sales to the base. If the sales are between $25,000 and $50,000, the program should add a bonus of 10% of sales. If the sales are between $50,000 and $100,000 it should add a bonus of 15% of sales. Sales over $100,000 merit a 20% of-sales bonus. Finally, the program should print the statement: The final salary of is $XXXX.XX and exit. -Modify the program so that input values are checked using a do-while & a for loop. How do these loops work in an event driven application versus a purely procedural application? Look at: SalesForceCompensationEventError web application

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 39

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 40

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 41 New HTML5 events for forms and input are at: They include: oninput, onfocus,onchange,onblur,onsubmit,onselect, onforminput, onformchange, oninvalid

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 42

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 43 Fun in Class Assignment: Try to get this page to work in your browser. Modify it so that it opens the duckduckgo website when the button is clicked. Hint:

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 44

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 45

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 46

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 47

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 48

Murach’s JavaScript, C2© 2009, Mike Murach & Associates, Inc.Slide 49

Slide 50 ImagesOnMouseOver Web Application -How many images are there? -How many sizes are there for each image? -How were these images created? (using Paint) - What happens to each image onmouseover? -What happens to each image onmouseout ? -How could we extend this to other forms of interactive web pages?

Slide 51 Fun In Class Assignment for functions Write a program that asks the user to key in strings, until the user types in *** to finish. Once the user has finished inputting the strings, the program prints out the string that had the maximum number of unique alphabets in it. It also prints out the count of these alphabets. To write this program, create a separate function called countAlpha(var s) that returns the number of unique alphabets in s. Create only one button on HTML page that is labeled: RunCountAlpha Sketch the overall code and the code for the function. Algorithm 1: Take all alphabets and check each one. Algorithm 2: Take first letter of string, scan forward. Eliminate duplicate characters. Then take second letter and repeat. Return length of final string. Use s=s..replace(/\s/g, ''); to remove whitespace after every pass.

Slide 52 Second Fun In Class Assignment for functions Take the homework assignment 2: building a calculator. Let us try to split this into functions -What functionality is repeated a lot? -How can we break the complex overall problem into parts that work independently but can call on each other?