Dynamic Web Authoring JavaScript – Looping statements COM311H Zheng, School of C&M, UUJ1.

Slides:



Advertisements
Similar presentations
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Arrays.
Advertisements

COM311H Zheng, School of C&M, UUJ1 Dynamic Web Authoring JavaScript Basics (Array and Function)
Tonight’s JavaScript Topics 1 Conditional Statements: if and switch The Array Object Looping Statements: for, while and do-while.
FORMs Lesson TBE 540. Prerequisites Before beginning this lesson, the learner must be able to… –Create basic web pages using a text editor and/or a web.
Technologies for web publishing Ing. Václav Freylich Lecture 4.
آموزش طراحی وب سایت جلسه یازدهم – جاوا اسکریپت 2 تدریس طراحی وب برای اطلاعات بیشتر تماس بگیرید تاو شماره تماس: پست الکترونیک :
CIS101 Introduction to Computing Week 12. Agenda Your questions Solutions to practice text Final HTML/JavaScript Project Copy and paste assignment JavaScript:
Web Database Programming Input Validation. User Input on the Web Web browser built-in mechanisms –HTML Forms HTTP POST method –Hyperlinks HTTP GET method.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Web-based Application Development Lecture 17 March 16, 2006 Anita Raja.
Information Technology Center Hany Abdelwahab Computer Specialist.
1 Lecture 14 Chapter 6 Looping Dale/Weems/Headington.
Introduction to JavaScript for Python Programmers
JavaScript Switch Statement. Switch JavaScript Switch Statement If you have a lot of conditions, you can use a switch statement instead of an if…elseif…
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
CST JavaScript Validating Form Data with JavaScript.
Mark Beattie Huiru (Jane) Zheng
Client-Side programming with JavaScript 3
Arrays and Control Structures CST 200 – JavaScript 2 –
4.1 JavaScript Introduction
JavaScript Form Validation
Using Arrays in PHP (Part I) Lecture # 6. What is an array? It is a collection of multiple values assembled into one variable An array can consist of.
Forms and Java script. Forms The graphical user interface -textbox, radio, button, textarea, checkbox… The processing script –CGI scripts, Perl script,
1 Forms A form is the usual way that information is gotten from a browser to a server –HTML has tags to create a collection of objects that implement this.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Dynamic Web Authoring Week 1 Practical feedback 09/09/2015COM311, H ZHENG, C&M, UUJ1.
Loops Doing the same thing over and over and over and over and over and over…
Arrays – What is it? – Creation – Changing the contents Functions – What is it? – Syntax – How they work – Anonymous functions A quick lesson in Objects.
>> Introduction to HTML: Tags. Hyper - is the opposite of linear Text – words / sentences / paragraphs Mark-up – Marking the text Language – It is a language.
Dynamic Web Authoring Week3 – Javascript Basic COM311H Zheng, School of C&M, UUJ1.
JavaScript For...In Statement The for...in statement loops through the elements of an array or through the properties of an object. Syntax for (variable.
XHTML 1.1  Derived from Standard Generalized Markup Language (SGML) of ISO  XHTML concerned primary with content rather than presentation and style 
CS-3432 Electronic Commerce Lecture – 13 Sikandar Shujah Toor
Web Technology Introduction to PHP. PHP PHP stands for PHP Hypertext Preprocessor PHP is a Server-Side Web Scripting language, which executes on the web.
Dynamic Web Authoring JavaScript – Array and function (2) COM311H Zheng, School of C&M, UUJ1.
Document Objects Forms, Images and Links. The document object model Each element of an HTML document, such as an image, form, link, or button, can be.
pop_up_windows // ALL STATEMENTS AFTER THE // ARE COMMENTS AND CAN BE REMOVED
1 JavaScript: Control Structures. 2 Control Structures Flowcharting JavaScript’s sequence structure.
1 JavaScript Functions and Objects. 2 Objectives You will be able to Use JavaScript functions in JavaScript scripts. Get JavaScript functions executed.
Iteration Chapter Iteration = Repetition 3 Looping Via The for Loop for loop: A block of code that executes a group of statements repeatedly until.
JavaScript Loops Please use speaker notes for additional information!
JavaScript, Fourth Edition
Select (drop-down list) Inputs. Insert/Form/List Menu.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
CIS 375—Web App Dev II JavaScript I. 2 Introduction to DTD JavaScript is a scripting language developed by ________. A scripting language is a lightweight.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
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.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Introduction to Programming the WWW I CMSC Summer 2003 Lecture 9.
JavaScript Arrays, Functions, and Forms George Mason University.
ECA 225 Applied Interactive Programming ECA 225 Applied Online Programming javascript arrays.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
JavaScript, Sixth Edition
Arrays and Loops. Learning Objectives By the end of this lecture, you should be able to: – Understand what a loop is – Appreciate the need for loops and.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 9 - JavaScript: Control Structures II Outline 9.1 Introduction 9.2 Essentials of Counter-Controlled.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
INTERNET APPLICATIONS CPIT405 Forms, Internal links, meta tags, search engine friendly websites.
Chapter 5 Murach's JavaScript and jQuery, C1© 2012, Mike Murach & Associates, Inc.Slide 1.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
INTERNET APPLICATIONS CPIT405 JavaScript Instructor: Rasha AlOmari
Week-11 (Lecture-1) Introduction to HTML programming: A web based markup language for web. Ex.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 11 - JavaScript: Arrays Outline 11.1 Introduction 11.2 Arrays 11.3 Declaring and Allocating Arrays.
JavaScript: Control Structures I Outline 1 Introduction 2 Algorithms 3 Pseudocode 4 Control Structures 5 if Selection Structure 6 if/else Selection Structure.
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
Dynamic Web Authoring form validation (1) COM311H Zheng, School of C&M, UUJ1.
HTML & teh internets.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Barb Ericson Georgia Institute of Technology May 2006
Chapter 6: Conditional Statements and Loops
Web Programming– UFCFB Lecture 16
Presentation transcript:

Dynamic Web Authoring JavaScript – Looping statements COM311H Zheng, School of C&M, UUJ1

Teaching Plan Feedback on Week5 practical Looping statements Week 6 practicals Submission of week1-6 learning log COM311 H Zheng, School of C&M, UUJ 2

Issues observed in Practical Using lecture notes and other reading material Make the function generic Reading list is available on Blackboard COM311 H Zheng, School of C&M, UUJ 3

JavaScript statement structure Sequential statements Looping statements Branch statements COM311 H Zheng, School of C&M, UUJ 4

Sequential statements Example: 1. var x=2; 2. var y=3; 3. var z=0; 4. var z=x+y; 5. document.write("The sum is: " + Z); COM311 H Zheng, School of C&M, UUJ 5

COM311 H Zheng, School of C&M, UUJ 6 Loops Doing things repeatedly – Loop control - Specifies what condition is necessary for the continued execution of the loop – Loop body - Statements that will be repeatedly executed as long as the loop control condition is satisfied – Three types of looping statements in Javascript

1. for Statement Syntax: for (initial expr.; test condition ; update expr.) { JavaScript statements comprising loop body } Example: var sum=0; for (i=1; i<=10; i++){ sum=sum+i; //sum+=i; } COM311 H Zheng, School of C&M, UUJ 7

2. While Statement Syntax: while (condition) { JavaScript statements comprising loop body } Example: var i=1; while(i<=10){ sum+=i; i++; } COM311 H Zheng, School of C&M, UUJ 8

COM311 H Zheng, School of C&M, UUJ 9 3. do…while statement Syntax: do{ JavaScript statements comprising loop body } while (condition); Example: var sum=0; do{ sum+=i; i++; }while(i<=10);

sum10.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " <!— var sum=0; do{ sum+=i; i++; }while(i<=10); window.alert("The sum is "+sum); //--> How to design a calculator to add …+n, n is the input from the user? COM311 H Zheng, School of C&M, UUJ 10

An example of loops listing2.2.html loop me <!-- for (i=5;i>1;i--){ document.write(i + " bottles of root beer on the wall. "); document.write("You take one down, pour a round. "); } document.write(" There is only one bottle of root beer left. "); document.write(" Now stop drinking all my root beer. "); //--> COM311 H Zheng, School of C&M, UUJ 11

Looping through an array var fruit=[‘apple’, ‘banana’, ‘pear’, ‘peach’]; How to display each fruit in each line? COM311 H Zheng, School of C&M, UUJ 12

Example – loop in array var fruit=["apple","pear","banana","peach"]; for (var i=0;i<4;i++) { document.write(fruit[i] + " "); } COM311 H Zheng, School of C&M, UUJ 13

Using the length property of the array var fruit=["apple","pear","banana","peach"]; for (var i=0; i<fruit.length; i++){ document.write(fruit[i] + " "); } COM311 H Zheng, School of C&M, UUJ 14

Array elements in html: Array object String Radio button Checkbox Selection menu Image sets ….. COM311 H Zheng, School of C&M, UUJ 15

Exercise How to loop into radio button/check box elements? Pay by cash Pay by card by phone by by post //get obj payment var thepayment=document.myform.payment; //using looping to display value of each item, how? COM311 H Zheng, School of C&M, UUJ 16

Summary feedback & response Learning log submission sequential statements looping statements COM311 H Zheng, School of C&M, UUJ 17