Faculty of Sciences and Social Sciences HOPE JavaScript Advanced Stewart Blakeway FML 213 0151 291 3113.

Slides:



Advertisements
Similar presentations
JavaScript and the DOM Les Carr COMP3001 Les Carr COMP3001.
Advertisements

Georgia Institute of Technology JavaScript part 2 Barb Ericson Georgia Institute of Technology May 2006.
Faculty of Sciences and Social Sciences HOPE Variables and Trace Tables Stewart Blakeway FML 213
Faculty of Sciences and Social Sciences HOPE PHP Flow Control Website Development Stewart Blakeway FML
Faculty of Sciences and Social Sciences HOPE Functions in PHP Stewart Blakeway FML
Faculty of Sciences and Social Sciences HOPE PHP – Working with Input Stewart Blakeway FML 213
Faculty of Sciences and Social Sciences HOPE Java: Loops within loops Stewart Blakeway FML 213
Multimedia and the World Wide Web HCI 201 Lecture Notes #8B.
MSc. Publishing on WWW JavaScript. What is JavaScript? A scripting language devised by Netscape Adds functionality to web pages by: Embedding code into.
1 The Information School of the University of Washington Oct 30fit review Programming Review INFO/CSE 100, Fall 2006 Fluency in Information Technology.
Computer Science 103 Chapter 4 Advanced JavaScript.
Tutorial 11 Working with Operators and Expressions
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
CST JavaScript Validating Form Data with JavaScript.
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.
JavaScript Form Validation
CNIT 133 Interactive Web Pags – JavaScript and AJAX Event and Event Handling.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT
Faculty of Sciences and Social Sciences HOPE JavaScript Validation Regular Expression Stewart Blakeway FML
Chapter 19: Adding JavaScript
Internet Mark-up Languages CO32036 Part Lecture: Elementary JavaScript.
JavaScript Informatics for economists I. Introduction Programming language used in web pages. Simple and easy to use – written in HTML document. Client.
CSS Class 7 Add JavaScript to your page Add event handlers Validate a form Open a new window Hide and show elements Swap images Debug JavaScript.
JavaScript: Functions © by Pearson Education, Inc. All Rights Reserved.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
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.
Event JavaScript's interaction with HTML is handled through events that occur when the user or browser manipulates a page. When the page loads, that is.
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES.
By Tharith Sriv. To write a web page you use: HHTML (HyperText Markup Language), AASP (Active Server Page), PPHP (HyperText Preprocessor), JJavaScript,
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT BY: SITI NURBAYA ISMAIL FACULTY of COMPUTER and MATHEMATICAL SCIENCES.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
1 JavaScript Part 3. Functions Allow the user to decide when a particular script should be run by the browser in stead of running as long as the page.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
Making dynamic pages with javascript Lecture 1. Java script java versus javascript Javascript is a scripting language that will allow you to add real.
COS 125 DAY 20. Agenda Assignment 8 not corrected yet Assignment 9 posted  Due April 16 New course time line Discussion on Scripts 
Javascript JavaScript is what is called a client-side scripting language:  a programming language that runs inside an Internet browser (a browser is also.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
7. JavaScript Events. 2 Motto: Do you think I can listen all day to such stuff? –Lewis Carroll.
JavaScript Events.
Tutorial 11 1 JavaScript Operators and Expressions.
LESSON : EVENTS AND FORM VALIDATION -JAVASCRIPT. EVENTS CLICK.
CGS 3066: Web Programming and Design Spring 2016 Programming in JavaScript.
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.
OVERVIEW OF CLIENT-SIDE SCRIPTING
Java Script Programming. Review: Event Handling Text Box Title: Button.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Popup Boxes.
Introduction to JavaScript Events Instructor: Sergey Goldman 1.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
JavaScript, Third Edition 1 SELECTION LIST Demo. JavaScript, Third Edition 2 Description This web page will edit the slection to ensure an option was.
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Handling events from DOM objects.
Third lecture Event 27/2/2016 JavaScript Tutorial.
Build in Objects In JavaScript, almost "everything" is an object.
Introduction to JavaScript Events
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
JavaScript.
Web Programming– UFCFB Lecture 17
JavaScript Events.
T. Jumana Abu Shmais – AOU - Riyadh
Today’s Objectives Week 12 Announcements ASP.NET
Training & Development
JavaScript and Ajax (JavaScript Events)
Web Programming and Design
Barb Ericson Georgia Institute of Technology May 2006
Web Programming and Design
Web Programming and Design
Presentation transcript:

Faculty of Sciences and Social Sciences HOPE JavaScript Advanced Stewart Blakeway FML

Faculty of Sciences and Social Sciences HOPE Objectives More JavaScript More Validation More Functions – Why Use Functions – Passing Arguments – Returning Values

Faculty of Sciences and Social Sciences HOPE Why use functions Web browsers will execute the JavaScript code before the HTML page loads – Sometimes you may not want the JavaScript to be executed until a specific time – You may want to use the JavaScript again and again – You may want several separate JavaScript scripts running on the same page

Faculty of Sciences and Social Sciences HOPE A simple function function displayMessage() { alert("Hello World!"); }

Faculty of Sciences and Social Sciences HOPE To call a function onclick = “functionname()” onkeydown = “functionname()” onkeypress = “functionname()” onkeyup = “functionname()” onmousemove = “functionname()” 21 Event Handlers in total.

Faculty of Sciences and Social Sciences HOPE Example Enter Telephone Number

Faculty of Sciences and Social Sciences HOPE function checkNum() { var pass = false; var telephone = document.getElementById("telnum").value; var last = telephone.length-1; for (var x=0 ; x <= 9 ; x++) { if (x==telephone[last]) { pass = true; } } if (pass == false) { window.alert("You are only allowed to put numbers"); } } pass false telephone last 7 x 0 false 1 Index [ ] telephone true

Faculty of Sciences and Social Sciences HOPE Passing Arguments Sometimes you will want to pass a value to a function

Faculty of Sciences and Social Sciences HOPE Seminar Example (passing arguments) If 0 – 9 is pressed deal with the input

Faculty of Sciences and Social Sciences HOPE The HTML

Faculty of Sciences and Social Sciences HOPE The Function function getNum(number) { document.form1.calcDisplay.value = (document.form1.calcDisplay.value + number); } Important This does not perform an addition. It concatenates!

Faculty of Sciences and Social Sciences HOPE Seminar Example (passing arguments) If divide, multiply, subtract or add is pressed deal with the input

Faculty of Sciences and Social Sciences HOPE The HTML

Faculty of Sciences and Social Sciences HOPE The Function function operator(symbol) { var running_total = document.getElementById("running_total").value; if (running_total == "") { document.form1.running_total.value = document.form1.calcDisplay.value; document.form1.calcDisplay.value = ""; document.form1.operator.value = symbol; } else { // next slide }

Faculty of Sciences and Social Sciences HOPE else if (document.form1.operator.value == "+") { document.form1.running_total.value = Number(document.form1.running_total.value) + Number(document.form1.calcDisplay.value); document.form1.operator.value = symbol; document.form1.calcDisplay.value = ""; }

Faculty of Sciences and Social Sciences HOPE Very crude? Although the calculator works – lacks finish – polish – completeness – functionality Can you do better? Start thinking about your design functionality To develop in your seminar, you can work in pairs.

Faculty of Sciences and Social Sciences HOPE Any Questions? Next week? Regular Expression