BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES

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 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
Session 8 JavaScript/Jscript: Objects Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
1 JavaScript/Jscript 6 Objects. 2 Introduction Up till now –JavaScript used to illustrate basic programming concepts JavaScript can also –Manipulate every.
Tutorial 11 Working with Operators and Expressions
JavaScript Objects Objects – JavaScript is an object-based language Has built-in objects we will use – You can create your own objects We concentrating.
Introduction to scripting
JavaScript Events and Event Handlers 1 An event is an action that occurs within a Web browser or Web document. An event handler is a statement that tells.
Using Object-Oriented JavaScript CST 200- JavaScript 4 –
Scripting Languages.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT
The Web Wizard’s Guide To JavaScript Chapter 6 Working with Dates and Times.
Working with background, images and date object Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
Copyright ©2005  Department of Computer & Information Science Using Number & Math Objects.
Objects.  Java Script is an OOP Language  So it allows you to make your own objects and make your own variable types  I will not be going over how.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
INE1020: Introduction to Internet Engineering 3: Web Page Authoring1 Lecture 6: Introduction to Javascript II r Javascript Objects Array String Date Math.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Objects.
Keeping it Neat: Functions and JavaScript Source Files Chapter 7.
CSC317 – INTERNET PROGRAMMING CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: MUHD EIZAN SHAFIQ BIN ABD AZIZ FACULTY of COMPUTER and MATHEMATICAL SCIENCES.
1 CSC317/318 INTERNET PROGRAMING / DYNAMIC WEB APPLICATION DEVELOPMENT Siti Nurbaya Ismail Faculty of Computer & Mathematical Sciences, Universiti Teknologi.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 13 – JavaScript/Jscript: Objects Outline 13.1Introduction 13.2Thinking About Objects 13.3.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES.
Project 1: Using Arrays and Manipulating Strings Essentials for Design JavaScript Level Two Michael Brooks.
Advanced JavaScript Topics – Page 1 of 31CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: Advanced JavaScript.
 2001 Deitel & Associates, Inc. All rights reserved. 1 Chapter 18 – JavaScript/Jscript: Objects Outline 18.1Introduction 18.2Thinking About Objects 18.3.
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES.
JS1-1 Introduction to JavaScript (JavaScript 1) Xingquan (Hill) Zhu
XP Tutorial 2 New Perspectives on JavaScript, Comprehensive1 Working with Operators and Expressions Creating a New Year’s Day Countdown Clock.
CSC317 – INTERNET PROGRAMMING CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES.
JavaScript: Objects 1 © by Pearson Education, Inc. All Rights Reserved.
Tutorial 11 1 JavaScript Operators and Expressions.
Slide 1 PHP Predefined Functions ITWA113. Murach’s ASP.NET 3.5/C#, C1© 2008, Mike Murach & Associates, Inc. Slide 2 PHP Predefined Functions Objectives.
JavaScript Tutorial. What is JavaScript JavaScript is the programming language of HTML and the Web Programming makes computers do what you want them to.
Chapter 9. An event-driven, object-based programming language that provides various types of functionality to pages. Object based: it is a language that.
Chapter 4 Java Script – Part2. 2 Location object Properties Properties href – whole path will be displayed. ex: window.location.href ( see example 11)
Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Third Edition by Tony Gaddis.
JavaScript Non Primitive Datatype
11 JavaScript: Objects.
Chapter 6 JavaScript: Introduction to Scripting
HTML & teh internets.
JavaScript Objects.
JavaScript: Functions
SEEM4570 Tutorial 05: JavaScript as OOP
Arab Open University - Riyadh
Java Script.
JavaScript Functions.
JavaScript Arrays Date
Introduction to Scripting
Week#3 Day#1 Java Script Course
JavaScript Syntax and Semantics
JavaScript: Functions.
JavaScript.
BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES
JavaScript: Objects.
Primitive Types Vs. Reference Types, Strings, Enumerations
Siti Nurbaya Ismail Senior Lecturer
Objects as Variables Featuring the Date Object
JavaScript: Introduction to Scripting
BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT
CSC318 – WEB APPLICATION DEVELOPMENT
JavaScript: Objects.
JavaScript: Introduction to Scripting
The Web Wizard’s Guide To JavaScript
Presentation transcript:

BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES CSC317 – INTERNET PROGRAMMING CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES

Outline Form Enhancement Javascript Array Mathematical Functions Page 2

Javascript Array Array What is an array? Temporary (storage|memory) of similar data Has 1 variable Store a group of data Text Numbers images Page 3

Javascript Array Array How to declare an array? var fav = new Array(); fav[0] = "cake"; fav[1] = "choco"; fav[2] = "mudpie"; var fav = new Array("cake","choco","mudpie"); var fav = ["cake","choco","mudpie"]; Page 4

Javascript Array Array Example 1 <script type="text/javascript"> // declare an array var biscuit = new Array(); // assign values on biscuit_name array biscuit[0] = "Almond Landon"; biscuit[1] = "Butter Finger"; biscuit[2] = "Snow Cornflakes"; biscuit[3] = "Tart Nenas"; // output value of biscuit_name array document.write(biscuit[2]); </script> Page 5

Javascript Array Array Example 2 <script type="text/javascript"> // declare an array var biscuit = new Array(); // assign values on biscuit array biscuit[0] = "Almond Landon"; biscuit[1] = "Butter Finger"; biscuit[2] = "Snow Cornflakes"; biscuit[3] = "Tart Nenas"; // output values of biscuit array for (x in biscuit){ document.write(biscuit[x] + "<br>"); } </script> Page 6

Javascript Array Array Example 3 <script type="text/javascript"> // declare an array var biscuit = new Array(); // assign values on biscuit array biscuit[0] = "Almond Landon"; biscuit[1] = "Butter Finger"; biscuit[2] = "Snow Cornflakes"; biscuit[3] = "Tart Nenas"; // output values of biscuit array for (i=0;i<=4;i++){ document.write(biscuit[i] + "<br>"); } </script> Page 7

Form Enhancement Performing Calculations Javascript Math Object The Math object allows you to perform mathematical tasks. JavaScript provides mathematical functions. Some of them are: random() : return a random number between 0 and 1 round() : round a number to the nearest integer max(x, y) : return larger number between x and y min(y, y) : return smaller number between x and y pow(x, y) : return xy To use all the functions, it must starts with Math.mathematical_functions Example: Math.pow(2,2) http://www.javascriptkit.com/jsref/math.shtml Page 8

Form Enhancement Performing Calculations <html> <body> <script type="text/javascript"> document.write(Math.random()); document.write("<br><br>"); document.write(Math.round(45.2)); document.write("Max is: " + Math.max(14, 7)); document.write("Min is: " + Math.min(14, 7)); document.write("10<sup>10</sup>: " + Math.pow(10, 2)); </script> </body> </html> Page 9

Form Enhancement Javascript Date Object Date objects are created with the new Date()  Once a Date object is created, a number of methods allow you to operate on it. Most methods simply allow you to get and set the year, month, day, hour, minute, second, and millisecond fields of the object, using either local time or UTC (universal, or GMT) time.

Form Enhancement Javascript Date Object new Date() With no arguments, the Date( ) constructor creates a Date object set to the current date and time. new Date(milliseconds) When one numeric argument is passed, it is taken as the internal numeric representation of the date in milliseconds, as returned by the getTime( ) method. For example, passing the argument 5000 creates a date that represents five seconds past midnight on 1/1/70. new Date(datestring) When one string argument is passed, it is a string representation of a date, in the format accepted by the Date.parse( ) method.

Form Enhancement Javascript Date Object new Date(year,month,date[,hour,minute,second,millisecond ]): year : Integer value representing the year. For compatibility (in order to avoid the Y2K problem), you should always specify the year in full; use 1998, rather than 98. month : Integer value representing the month, beginning with 0 for January to 11 for December. date : Integer value representing the day of the month. hour : Integer value representing the hour of the day (24-hour scale). minute : Integer value representing the minute segment of a time reading. second : Integer value representing the second segment of a time reading. millisecond : Integer value representing the millisecond segment of a time reading.

Form Enhancement Getter Methods All access to date/time components is carried out through methods. getFullYear() Get 4-digit year getMonth() Get month, from 0 to 11 getDay() Get the number of day in a week, from 0(Sunday) to 6(Saturday) getDate() Get day, from 1 to 31 getDay() getHours() getMinutes() getSeconds() getMilliseconds()

Form Enhancement Javascript Date Object Example 1 Use getDay() and an array to write a weekday, and not just a number as shown in the following example: Today is Tuesday Example 2 Display the current date using the date object in the format of DD/MM/YYYY as shown in the following example: Today date is 28/01/2014 Example 3 Display the current time using the date object in the format of HH:MM AM/PM (H = Hour, M = Minute as shown in the following example: It is now 15.30 PM

Form Enhancement Javascript String Object The String object is used to manipulate a stored piece of text. Some of them are: charAt() : returns the character at the spesific index concat() : joins two or more string, and return a copy of the joined string split() : splits a string into an array of substrings substring(): extracts the characters from a string, between two specified indices join() : join the elements of an array into a string Example: var str = "HELLO WORLD"; var n = str.charAt(2); document.write(n); output L Page 15

Exercise 1 Page 16

Exercise 2 Page 17

Exercise 3 Page 18

Exercise 4 Page 19

Exercise 5 Page 20

Exercise 6 Page 21

Exercise 7 Page 22

Exercise 8 Page 23

Exercise 9 Page 24

Exercise 10 Page 25

Exercise 11 Page 26

Exercise 12 Page 27

Exercise 12 (continue) Page 28

Bibliography (Website) Bibliography (Book) Knuckles (2001). Introduction to Interactive Programming on the Internet using HTML & Javascript. John Wiley & Sons, Inc. http://www.w3schools.com/js/default.asp http://www.javascriptkit.com/jsref/math.shtml http://www.w3schools.com/jsref/jsref_obj_string.asp Bibliography (Website) Page 29 29