Computer Information System Information System California State University Los Angeles Jongwook Woo CIS 461 Web Development I Javascript Jongwook Woo,

Slides:



Advertisements
Similar presentations
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
Advertisements

Javascript Introduction Norman White Material is from w3schools.com Go there to run examples interactively.
14/11/11.  These words have special meanings in themselves  These should NOT be used as Identifiers.  For example:  Break, do, function, case, else,
HTML Forms JavaScript Introduction / Overview Lab Homework #1 CS 183 4/8/2010.
Introduction to Web Site Development Steven Emory Department of Computer Science California State University, Los Angeles Lecture 8: JavaScript I.
Web Page Behavior IS 373—Web Standards Todd Will.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
آموزش طراحی وب سایت جلسه دهم – جاوا اسکریپت 1 تدریس طراحی وب برای اطلاعات بیشتر تماس بگیرید تاو شماره تماس: پست الکترونیک :
JavaScript CMPT 281. Outline Introduction to JavaScript Resources What is JavaScript? JavaScript in web pages.
Adding JavaScript (<script tag>)
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
INTERNET APPLICATION DEVELOPMENT For More visit:
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
SYST Web Technologies SYST Web Technologies Lesson 6 – Intro to JavaScript.
Week 9 PHP Cookies and Session Introduction to JavaScript.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
CC1003N Week 6 More CSS and Javascript.. Objectives: ● More CSS Examples ● Javascript – introduction ● Uses of Javascript ● Variables ● Comments ● Control.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
2440: 211 Interactive Web Programming Expressions & Operators.
What is Java Script? An extension to HTML. An extension to HTML. Allows authors to incorporate some functionality in their web pages. (without using CGI.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
LOGO Introduction to Client-Side Scripting and JavaScript CHAPTER 9 Eastern Mediterranean University School of Computing and Technology Department of Information.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
1 JavaScript
JavaScript Syntax, how to use it in a HTML document
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
JavaScript. JavaScript is the programming language of HTML and the Web. Easy to learn One of the 3 languages of all developers MUST learn: 1. HTML to.
COMP403 Web Design JAVA SCRİPTS Tolgay KARANFİLLER.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
CHAPTER 6 Introduction to PHP5 Part I อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Pertemuan 5 IT133 Pengembangan Web JavaScript. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
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.
Computer Information System Information System California State University Los Angeles Jongwook Woo CIS 461 Web Development I HTML DOM part I Jongwook.
This is our seminar JavaScript And DOM This is our seminar JavaScript And DOM.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
JavaScript Tutorial. What is JavaScript JavaScript is the programming language of HTML and the Web Programming makes computers do what you want them to.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
JavaScript Introduction JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer,
JavaScript Tutorial First lecture 19/2/2016. Javascript is a dynamic computer programming language. It is lightweight and most commonly used as a part.
Introduction to Client-Side Scripting and JavaScript
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
My First Web Page document.write("" + Date() + ""); To insert.
JavaScript Syntax and Semantics
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
PHP Introduction.
JavaScript.
Introduction to Client-Side Scripting and JavaScript
PHP.
My First Web Page document.write("" + Date() + ""); To insert.
T. Jumana Abu Shmais – AOU - Riyadh
JavaScript Defined General Syntax Body vs. Head Variables Math & Logic
CS105 Introduction to Computer Concepts
Tutorial 10: Programming with javascript
Web Programming– UFCFB Lecture 13
Web Programming and Design
CS105 Introduction to Computer Concepts JavaScript
Presentation transcript:

Computer Information System Information System California State University Los Angeles Jongwook Woo CIS 461 Web Development I Javascript Jongwook Woo, PhD California State University, Los Angeles Computer Information System Department

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System Content nStatements nComments nVariables nOperators nFunctions nLoops

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System nTHE scripting language of the Web. madd interactivity to HTML pages ma lightweight programming language musually embedded directly into HTML pages man interpreted language –means that scripts execute without preliminary compilation –That runs on client site, that is, web browser mEveryone can use JavaScript without purchasing a license nused in billions of Web pages mto add functionality, validate forms, communicate with the server, and much more JavaScript

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System What can JavaScript do? nJavaScript gives HTML designers a programming tool mAlmost anyone can put small "snippets" of code into their HTML pages nJavaScript can react to events – mexecute when something happens, –like when a user clicks on an HTML element nJavaScript can read and write HTML elements mcan read and change the content of an HTML element nJavaScript can be used to validate data mused to validate form data before it is submitted to a server

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System What can JavaScript do? (Cont’d) nJavaScript can be used to detect the visitor's browser mload another page specifically designed for that browser nJavaScript can be used to create cookies mused to store and retrieve information on the visitor's computer

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System Statements nJavaScript is Case Sensitive mUnlike HTML, watch your capitalization closely nA JavaScript statement mis a command to a browser. –to tell the browser what to do. document.write("Hello Dolly"); mtells the browser to write "Hello Dolly" to the web page: mThe semicolon is optional (according to the JavaScript standard), –the end of the statement. –a good programming practice. –Note: Using semicolons makes it possible to write multiple statements on one line.

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System JavaScript Codes nis a sequence of JavaScript statements. nExample document.write(" This is a heading "); document.write(" This is a paragraph. "); document.write(" This is another paragraph. ");

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System JavaScript Blocks nJavaScript statements can be grouped together in blocks. mto make the sequence of statements execute together. nBlocks start with a left curly bracket {, mand end with a right curly bracket } nExample { document.write(" This is a heading "); document.write(" This is a paragraph. "); document.write(" This is another paragraph. "); }

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System JavaScript Comments nmake the code more readable nSingle line comments start with // // Write a heading document.write(" This is a heading "); // heading nJavaScript Multi-Line Comments mMulti line comments start with /* and end with */. mThe following example uses a multi line comment to explain the code: /* The code below will write one heading and two paragraphs */ document.write(" This is a heading ");

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System JavaScript Variables nused to hold values or expressions mAs with algebra ndeclare JavaScript variables with the var keyword: var x; var carname; mthe variables are empty (they have no values yet). nyou can also assign values to the variables var x=5; var carname="Volvo"; mAfter the execution of the statements above, the variable x will hold the value 5, –and carname will hold the value Volvo. mNote: When you assign a text value to a variable, use quotes around the value.

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System Rules for JavaScript variable names nVariable names are case sensitive m(y and Y are two different variables) mNote: Because JavaScript is case-sensitive, variable names are case- sensitive. nVariable names must begin mwith a letter or the underscore character nLocal JavaScript Variables mA variable declared within a JavaScript function becomes LOCAL –and can only be accessed within that function. –the variable has local scope mLocal variables are destroyed when you exit the function.

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System JavaScript variables nGlobal JavaScript Variables mVariables declared outside a function become GLOBAL, –and all scripts and functions on the web page can access it. mGlobal variables are destroyed when you close the page. mIf you declare a variable, without using "var", the variable always becomes GLOBAL. nAssigning Values to Undeclared JavaScript Variables mThese statements: x=5; carname="Volvo"; mwill declare the variables x and carname as global variables (if they don't already exist).

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System Arithmetic Operators n= is used to assign values. n+ is used to add values. y=5; z=2; x=y+z; mThe value of x, after the execution of the statements above, is 7. nThe + Operator Used on Strings mused to add string variables or text values together. mTo add two or more string variables together, use the + operator. txt1="What a very"; txt2="nice day"; txt3=txt1+txt2; mAfter the execution of the statements above, the variable txt3 contains "What a verynice day".

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System Arithmetic Operators (Given that y=5) OperatorDescriptionExampleResult +Additionx=y+2 x=7y=5 -Subtractionx=y-2 x=3y=5 *Multiplicatio n x=y*2 x=10y=5 /Divisionx=y/2 x=2.5y=5 %Modulus (division remainder) x=y%2 x=1y=5 ++Incrementx=++y x=6y=6 x=y++ x=5y=6 --Decrementx=--y x=4y=4 x=y-- x=5y=4

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System Comparison Operators (Given that x=5) OperatorDescriptionExample ==is equal tox==8 is false x==5 is true ===is exactly equal to (value and type) x===5 is true x==="5" is false !=is not equalx!=8 is true >is greater thanx>8 is false <is less thanx<8 is true >=is greater than or equal to x>=8 is false <=is less than or equal tox<=8 is true

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System Logical Operators nLogical operators are used to determine the logic between variables or values. n&&: both operands should be true to have the result true n||: at least one operand should be true to have the result true OperatorDescriptionExample &&and(x 1) is true ||or(x==5 || y==5) is false !not!(x==y) is true

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System Functions nIn Math: mFunction declaration: –f(x) = x + 1 mFunction call: y = f(x) when x = 2 –What is y? nFunction Syntax in JavaScript function functionname(var1,var2,...,varX) { some code } mThe parameters var1, var2, etc. are variables or values passed into the function. The { and the } defines the start and end of the function.

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System Functions (Example) function displaymessage() { alert("Hello World!"); }

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System Functions with Return Statement nspecify the value that is returned from the function. function product(a,b) { return a*b; } document.write(product(4,3));

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System Loop nwant the same block of code to run over and over again in a row. nIn JavaScript, there are two different kind of loops: mfor - loops through a block of code a specified number of times mwhile - loops through a block of code while a specified condition is true nThe for Loop mThe for loop is used when you know in advance how many times the script should run. for (variable=startvalue; variable<=endvalue; variable=variable+increment) { code to be executed }

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System For Loop var i=0; for (i=0;i "); } The number is 0 The number is 1 The number is 2 … The number is 5