CIS 375—Web App Dev II JavaScript II.

Slides:



Advertisements
Similar presentations
Tonight’s JavaScript Topics 1 Conditional Statements: if and switch The Array Object Looping Statements: for, while and do-while.
Advertisements

Creating PHP Pages Chapter 7 PHP Decisions Making.
Objectives Using functions to organize PHP code
1 CS101 Introduction to Computing Lecture 23 Flow Control & Loops (Web Development Lecture 8)
PHP Functions and Control Structures. 2 Defining Functions Functions are groups of statements that you can execute as a single unit Function definitions.
14/11/11.  These words have special meanings in themselves  These should NOT be used as Identifiers.  For example:  Break, do, function, case, else,
Executes a statement or statements for a number of times – iteration. Syntax for(initialize; test; increment) { // statements to be executed } Initial.
HTML Forms JavaScript Introduction / Overview Lab Homework #1 CS 183 4/8/2010.
ITC 240: Web Application Programming SUBHASH PRAJAPATI 04/14/15.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Selection Statements choice of one among several blocks of code Java supports 3 kinds of selection statements: if statement – selects one block or leaves.
Chapter 4 Functions and Control Structures PHP Programming with MySQL.
Computer Programming 1 Repetition. Computer Programming 2 Objectives Repetition structures Study while and do loops Examine for loops A practical example.
Tutorial 4 Decision Making with Control Structures and Statements Section A - Decision Making JavaScript Tutorial 4 -Decision Making with Control.
If () else statement, switch statement, while () loop, do…while() loop and for( ; ; ) loop 1.
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…
An Introduction to C Programming Geb Thomas. Learning Objectives Learn how to write and compile a C program Learn what C libraries are Understand the.
آموزش طراحی وب سایت جلسه دهم – جاوا اسکریپت 1 تدریس طراحی وب برای اطلاعات بیشتر تماس بگیرید تاو شماره تماس: پست الکترونیک :
Client-Side programming with JavaScript 3
Arrays and Control Structures CST 200 – JavaScript 2 –
Javascript fundamentals (continue). Visual Web Developer wd/download/
Programming with JavaScript (Chapter 10). XP Various things Midterm grades: Friday Winter Career Fair – Thursday, April 28, 2011 (11 am to 3 pm). – MAC.
Conditional Statements While writing a program, there may be a situation when you need to adopt one path out of the given two paths. So you need to make.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
PHP Conditional Statements Conditional statements in PHP are used to perform different actions based on different conditions. Conditional Statements Very.
PHP Programming with MySQL Slide 4-1 CHAPTER 4 Functions and Control Structures.
Chapter 2 Functions and Control Structures PHP Programming with MySQL 2 nd Edition.
Chapter 3. Outline Relational Operators Loops Decisions Logical Operators Precedence Summary.
LOGO Conditional Statements & Loops in JavaScript CHAPTER 10 Eastern Mediterranean University School of Computing and Technology Department of Information.
L OO P S While writing a program, there may be a situation when you need to perform some action over and over again. In such situation you would need.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
JavaScript, Fourth Edition
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 10 - JavaScript/JScript: Control Structures II Outline 10.1Introduction 10.2Essentials of.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
JavaScript Jordan Clark, Jamie Kapilivsky, Taylor Monk, Jessica Torres.
COMP403 Web Design JAVA SCRİPTS Tolgay KARANFİLLER.
VBScript Conditional Statements. Conditional Statements Very often when you write code, you want to perform different actions for different decisions.
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.
Control Structures, Blocks and Compound Statements A good programming language allows you to control the flow of your program in three ways: - execute.
1 Chapter 3: Loops and Logic. 2 Control Statements If statement Example NumberCheck.java Relational operators (, >=, ==, !=) Using code blocks with If.
Working with Loops, Conditional Statements, and Arrays.
In God we trust Learning Java Script. Java Script JavaScript is the scripting language of the Web! JavaScript is used in millions of Web pages to improve.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Web Development JavaScript. Introduction to JavaScript.
CSI 3125, Preliminaries, page 1 Control Statements.
1 CS428 Web Engineering Lecture 13 Flow Control & Loops (JavaScript - III)
Chapter 9: Control Statements II CIS 275—Web Application Development for Business I.
XP Tutorial 3 New Perspectives on JavaScript, Comprehensive1 Working with Arrays, Loops, and Conditional Statements Creating a Monthly Calendar.
Chapter 5: Intro to Scripting CIS 275—Web Application Development for Business I.
JavaScript, Sixth Edition
JavaScript JavaScript ( Condition and Loops ). Conditional Statements If Statement If...else Statement if (condition) { code to be executed if condition.
 Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do.
PHP Condtions and Loops Prepared by Dr. Maher Abuhamdeh.
Web Systems & Technologies
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Loops in Java.
My First Web Page document.write("" + Date() + ""); To insert.
CiS 260: App Dev I Chapter 4: Control Structures II.
Ch 7: JavaScript Control Statements I.
Expressions and Control Flow in JavaScript
Chapter 19 JavaScript.
JavaScript: Control Statements (II)
IF if (condition) { Process… }
During the last lecture we had a discussion on Data Types, Variables & Operators
My First Web Page document.write("" + Date() + ""); To insert.
Conditional Statements & Loops in JavaScript
Program Flow.
PROGRAM FLOWCHART Iteration Statements.
CIS 136 Building Mobile Apps
Presentation transcript:

CIS 375—Web App Dev II JavaScript II

if and if…else Syntax code to be executed if condition is true } else {

Example of if Statement // Display “Good morning” if before 10 am var today = new Date() var time = today.getHours() if (time < 10) { document.write("<b>Good morning</b>") }

Example of if…else Statement // Display “Good morning” if before 10 am // Display “Good day!” otherwise var today = new Date() var time = today.getHours() if (time < 10) { document.write("<b>Good morning</b>") } else { document.write("Good day!")

Syntax of switch Statement switch (expression) { case label1: code to be executed if expression = label1 break case label2: code to be executed if expression = label2 default: code to be executed if expression is different from both label1 and label2 }

Example of switch Statement var today = new Date() theDay = today.getDay() switch (theDay) { case 5: document.write("Finally Friday") break case 6: document.write("Super Saturday") case 0: document.write("Sleepy Sunday") default: document.write(“Can’t wait till the weekend!”) }

Syntax for Looping while do…while while (condition) { code to be executed } do…while do { while (condition) for (equivalent to _______ with a counter variable) for (initialization; condition; increment) {

Examples of while & do…while while (i <= 5){ document.write("The number is " + i) document.write("<br>") i++ } do…while do{ while (i <= 5)

Example of for Loop for (i = 1; i <= 6; i++){ document.write("<h" +i+ ">This is header " + i) document.write("</h" + i + ">") }

Miscellaneous Guidelines JavaScript is ______ sensitive A function named "myfunction" is not the same as "myFunction". White space (use to make code more ___________) JavaScript ignores extra spaces name="Hege" same as name = "Hege“ Use the “\” to insert special characters document.write (“Let’s sing \"Happy Birthday\".") Comments Use // for single line, /* comments */ for a block