CHAPTER 10 JAVA SCRIPT.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
The Web Warrior Guide to Web Design Technologies
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Introduction to Web Site Development Steven Emory Department of Computer Science California State University, Los Angeles Lecture 8: JavaScript I.
Web Development & Design Foundations with XHTML Chapter 14 Key Concepts.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Introduction to JavaScript for Python Programmers
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Introduction to scripting
CST JavaScript Validating Form Data with JavaScript.
Javascript and the Web Whys and Hows of Javascript.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
SYST Web Technologies SYST Web Technologies Lesson 6 – Intro to JavaScript.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
Using Client-Side Scripts to Enhance Web Applications 1.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
JavaScript Adding active content to websites. Goals Understand structure of JavaScript Understand rules of coding Add active content to WebPages Add functions.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
1 JavaScript
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
1 A Balanced Introduction to Computer Science David Reed, Creighton University ©2005 Pearson Prentice Hall ISBN X Chapter 4 JavaScript and.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
JavaScript, Fourth Edition
COMP403 Web Design JAVA SCRİPTS Tolgay KARANFİLLER.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Making dynamic pages with javascript Lecture 1. Java script java versus javascript Javascript is a scripting language that will allow you to add real.
Pertemuan 5 IT133 Pengembangan Web JavaScript. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
1 JavaScript and Dynamic Web Pages Lecture 7. 2 Static vs. Dynamic Pages  A Web page uses HTML tags to identify page content and formatting information.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
© 2010 Robert K. Moniot1 Chapter 6 Introduction to JavaScript.
>> Introduction to JavaScript
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Chapter 6 JavaScript: Introduction to Scripting
Web Development & Design Foundations with HTML5
JavaScript is a programming language designed for Web pages.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Web Development & Design Foundations with HTML5 7th Edition
WEB APPLICATION PROGRAMMING
Introduction to Scripting
JavaScript: Functions.
JavaScript.
Week#2 Day#1 Java Script Course
CHAPTER 4 CLIENT SIDE SCRIPTING PART 2 OF 3
The structure of computer programs
WEB PROGRAMMING JavaScript.
Introduction to JavaScript for Python Programmers
T. Jumana Abu Shmais – AOU - Riyadh
JavaScript What is JavaScript? What can JavaScript do?
CS105 Introduction to Computer Concepts
JavaScript What is JavaScript? What can JavaScript do?
Web Development & Design Foundations with H T M L 5
Tutorial 10: Programming with javascript
JavaScript Basics What is JavaScript?
JavaScript: Introduction to Scripting
Web Programming– UFCFB Lecture 13
Web Programming and Design
CS105 Introduction to Computer Concepts JavaScript
Presentation transcript:

CHAPTER 10 JAVA SCRIPT

JAVA SCRIPT Language that will allow you to add real programming to your web pages. Most of the browser today have their JavaScript interpreter. We used JavaScript for: Browser Detection-Detecting the browser used by a visitor at your page. Cookies- To store the information on the visitor computer and then retrieve this information automatic next time the user visit your page. Control Browsers- Opening pages in customized windows, where you specify if the browsers buttons, menu line, status line or whatever should be present. Validate Forms-Validating inputs to fields before submitting a form.

Syntax : <Script language=“JavaScript”> </Script> HOW TO ADD JAVA SCRIPT This script tell the browser where JavaScript starts and ends. Syntax : <Script language=“JavaScript”> </Script> Example: <HTML> <BODY> <Script language =“JavaScript”> //type the message/text </Script> </BODY> </HTML>

IMPORTANT ! A few things you need to know before you write a JavaScript code : JavaScript-lines ends with a semicolon(;). Should always put the text within “ ”. If you forget to enclose your text in “ ”, JavaScript will interpret your text as being variables rather than text. Capital letter are different from non-capital letters.(so you need to follow the capital letters at exactly the right places)

VARIABLES All variables are referred to the unique name you assigned to them. The variable with capital letter is difference with variable non-capital letters. Example: Myname , MyName.

ASSIGN VALUE TO VARIABLE Used equal-sign. We can assign a value or text to variables. Example: Assigned a text to variables: FirstName=“Dit4”; Assigned a value to variables: a= 3; a++; Used a standard operator such as -, +, * and / in our web page. We also can used ++, -- and % operator for increment, decrement and returns modulus value to a variable. a=2; b=a++; FirstName=“AIM”; LastName=“Alor Setar”; FullName=FirstName+ “ ”+LastName;

MESSAGE BOX Three pop-up windows that we can add in our web pages. alertbox confirmbox promptbox

ALERTBOX Used when we want to make sure an information comes through to the user. Syntax: alert (“text”); Example: alert(“Welcome to my homepage”); Message box windows will provide the “OK” button. So user need to click “OK” to proceed.

COMFIRMBOX Used when we want the user to agree to or accept something. Syntax: confirm (“your text”); Example: confirm (“You are 20 years old”); Message box window will provide the “OK” and “ Cancel” button, so user need to click “OK” button or “CANCEL” button to proceed. “OK” – returns the value true “CANCEL” – returns the value false.

PROMPBOX Used when the user should input a value before entering the page. Example: enter username, password. Used together with variables. Syntax: prompt (“your text”, “default value”); Example: Username= prompt(“please enter your name”, “enter your name here”); User need to click “OK” button or “CANCEL” button after entering the text. “OK” – the promptbox returns the entry. “CANCEL” – the promptbox returns null.

SELECTION The selection control structure in JavaScript are: If selection If/else selection Nested if selection Multiple selection (switch) Comparing operator : = = equal to != not equal to < less than > greater than < = less than or equal to > = greater than or equal to

IF SELECTION Syntax: if (condition){action 1}; Example: if (browser ==“Mozila Firefox”) { alert (“you are using Mozila Firefox”) };

IF/ELSE SELECTION Syntax: if (condition){action 1} else {action 2}; Example: if (browser ==“Mozila Firefox”) { alert (“you are using Mozila Firefox”) } else alert (“you are using Netscape”) };

NESTED IF Syntax: if (condition) { {action 2} else {action 3} }; Example: a= prompt(“please enter first number”, “0”); b= prompt (“please enter second number”, “0”);   if (a==b) { if (a>0) Alert (“both number are equal and a is positive number”); } }; Syntax: if (condition) { {action 2} else {action 3} };

MULTIPLE SELECTION (SWITCH) Is used to handle decision making. Syntax: switch (variablename) { case “label_1” : statements_1; break; case “label_2” : statements_2; break; case “label_n” : statement_n; break; default: statements; }

BOOLEAN OPERATOR We call as a logical operator and use to enhance our if statement. Example of logical operator: AND (&&), OR (||) and NOT (!). AND - Use when we want to check if more than one condition to be true. OR- Use when we want to check if more than one condition should result in the check being true. NOT- Use to invert whatever we are checking for.

LOOP Used to make sure we can display data for more then one times. 3 different loop: for loop while loop do while loop

FOR LOOP & WHILE LOOP FOR LOOP Used when we know in advance how many times the script should perform the similar task. Syntax: for (variable=startvalue; variable<=endvalue; variable= variable + incrementfactot) WHILE LOOP Used when we don’t know in advance how many times the loop should be performed. while (variable <=endvalue) { //type the JavaScript code,increment and decrement }

DO WHILE LOOP Used when we don’t know in advance how many times the loop should be performed. Same with while loop, but in do.. While its test the condition at the end of the loop body. The loop body always executed at least once.   Syntax do { //type the JavaScript code; Increment/ decrement; } while (variable <=endvalue);

FUNCTION The best way to develop and maintain a large program is to construct it small, simple pieces or modules. Modules in JavaScript are called functions. JavaScript programs are written by combining new functions that the programmer writes with “prepackaged” functions and object available in JavaScript. The “prepackaged” functions that belong to JavaScript objects (such as Math.pow and Math.round) are often called methods.

JavaScript provides several objects that have a rich collection of methods for performing common mathematical calculations, string manipulations, date and time manipulations and manipulations of collections of data called Arrays. The programmer can write functions to define specific tasks that may be used at many points in a script (referred as a programmer-defined functions). A function is invoked by a function call. The function call specifies the function name and provides information (as arguments) that the called function needs to do its task.

USER DEFINED FUNCTION Syntax: function functionname (variable1,variable2….) { //here goes the Javascript for the function } Must be type after <script Language=…> Must be spelled exactly as function. To call the function, just called the functionname that you give for your function.  

ARRAY An array is a group of memory location that all have same name and same type. Array is used to help us to automate the process. When using variable-array, we need to define the array before referring it to any of the variable. 2 types of array: One Dimension Two Dimension

ONE DIMENSIONAL ARRAY Syntax: Variablename=new Array; Example: Assign data to array by using looping: var value=new Array; for (number=1; number<=100; number= number + 1) { value[number]= number * 10; };