5 th and 4 th ed: some from chapters 9, 12, 13 SY306 Web and Databases for Cyber Operations Slide Set #8: Dynamic HTML.

Slides:



Advertisements
Similar presentations
Computer and Communication Fundamental Basic web programming Lecture 8 Rina Zviel-Girshin.
Advertisements

JavaScript and the DOM Les Carr COMP3001 Les Carr COMP3001.
Georgia Institute of Technology JavaScript part 2 Barb Ericson Georgia Institute of Technology May 2006.
JavaScript (Part 2) CS 183 4/13/2010. JavaScript (Part 2) Will cover: ◦ For.. In ◦ Events ◦ Try.. Catch, Throw ◦ Objects.
Chapter 7 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 7 Sebesta: Programming the World Wide Web.
20-Jun-15 JavaScript and HTML Simple Event Handling.
JavaScript Bartosz Sakowicz. JavaScript - basics JavaScript is used in millions of Web pages to improve the design, validate forms, detect browsers, create.
Computer Science 103 Chapter 4 Advanced JavaScript.
Lesson 2 Event Handling. Object Event Handlers Most of the objects that make up the Document Object Model respond to asynchronous, user generated events.
JavaScript Client Side scripting. Client-side Scripts Client-side scripts, which run on the user’s workstation can be used to: Validate user inputs entered.
UNIT 6 JAVASCRIPT EVENT HANDLERS &WEB BROWSERS DETECTION.
CP476 Internet Computing JavaScript and HTML1 1.JavaScript Execution Environment The JavaScript Window object represents the window in which the browser.
JS: DOM Form Form Object Form Object –The Form object represents an HTML form. –For each instance of a tag in an HTML document, a Form object is created.
HTML Forms/Events (Instructor Lesson) The Event model HTML Forms Custom Events 1.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Event and Event Handling.
Introduction to JavaScript. JavaScript Facts A scripting language - not compiled but interpreted line by line at run-time. Platform independent. It is.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
Chapter 19: Adding JavaScript
Chapter 5 © 2003 by Addison-Wesley, Inc. 1 Chapter 5 JavaScript and HTML Documents.
JavaScript II ECT 270 Robin Burke. Outline JavaScript review Processing Syntax Events and event handling Form validation.
JavaScript Part 1.
1 JavaScript: Event Model November 1, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel, and Goldberg.
JavaScript Lecture 6 Rachel A Ober
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.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 14 - Dynamic HTML: Event Model Outline 14.1 Introduction 14.2 Event onclick 14.3 Event onload 14.4.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
Intro to JavaScript Scripting language –ECMAScript compliant –Client side vs. server side Syntactic rules –White space –Statement end: ; optional –Comments:
Lecture 10 JavaScript: DOM and Dynamic HTML Boriana Koleva Room: C54
44238: Dynamic Web-site Development Client Side Programming Ian Perry Room:C48 Extension:7287
1 JavaScript 2 JavaScript. 2 Rollovers Most web page developers first use JavaScript for rollovers A rollover is a change in the appearance of an element.
Scott Marino MSMIS Summer Session Web Site Design and Authoring Session 8 Scott Marino.
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.
Client-Side programming with JavaScript 2. Event-driven programs and HTML form elements event-driven programs  onload, onunload  HTML forms & attributes.
Active X – Mouse Events. Structured Graphics Control  Included in Internet Explorer v5.0  Add to page with the OBJECT tag  Accessible via scripting.
 2003 Prentice Hall, Inc. All rights reserved. Chapter 14 - Dynamic HTML: Event Model Outline 14.1 Introduction 14.2 Event onclick 14.3 Event onload 14.4.
Jaana Holvikivi 1 Introduction to Javascript Jaana Holvikivi Metropolia.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
Making dynamic pages with javascript Lecture 1. Java script java versus javascript Javascript is a scripting language that will allow you to add real.
Event Handling. Objectives Using event handlers Simulating events Using event-related methods.
Project 8: Reacting to Events Essentials for Design JavaScript Level One Michael Brooks.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
COS 125 DAY 20. Agenda Assignment 8 not corrected yet Assignment 9 posted  Due April 16 New course time line Discussion on Scripts 
Web Programming Java Script & jQuery Web Programming.
HTML FORMS The TEXT Object Presented By: Ankit Gupta.
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.
H.Melikyan/4910/031 Programming the World Wide Web JavaScript Dr.Hayk Melikyan Departmen of Mathematics and CS JavaScript and HTML Documents.
JavaScript II ECT 270 Robin Burke. Outline Functions Events and event handling Form validation.
JavaScript Events.
JavaScript Event Handlers. Introduction An event handler executes a segment of a code based on certain events occurring within the application, such as.
LESSON : EVENTS AND FORM VALIDATION -JAVASCRIPT. EVENTS CLICK.
Event Handlers Events are asynchronous. When an event occurs, JavaScript can execute code in response to the user’s action. This response to the user-initiated.
Chapter 4 Java Script - Part1. 2 Outlines Introduction to Java Script Variables, Operators and Functions Conditional statements JavaScript Objects Forms.
Introduction to JavaScript Events Instructor: Sergey Goldman 1.
Functions Wouldn’t it be nice to be able to bring up a new animal and paragraph without having to reload the page each time? We can! We can place the.
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Handling events from DOM objects.
Methods and Object Information. Some Document Methods.
Build in Objects In JavaScript, almost "everything" is an object.
JavaScript and HTML Simple Event Handling 11-May-18.
JavaScript (JS) Basics
JAVASCRIPTS AND HTML DOCUMENTS
JavaScript and HTML Simple Event Handling 19-Sep-18.
Chapter 14 - Dynamic HTML: Event Model
JavaScript Events.
JavaScript and Ajax (JavaScript Events)
JAVA SCRIPT OBJECTS & DOM
Barb Ericson Georgia Institute of Technology May 2006
JavaScript and HTML Simple Event Handling 26-Aug-19.
Murach's JavaScript and jQuery (3rd Ed.)
JavaScript and HTML Simple Event Handling 4-Oct-19.
Presentation transcript:

5 th and 4 th ed: some from chapters 9, 12, 13 SY306 Web and Databases for Cyber Operations Slide Set #8: Dynamic HTML

What can we do with DHTML

What can we do with DHTML?

Event-Driven Programming and DOM Events Event handlers DOM

DHTML - What techniques do we need? Find the HTML object we want to change var domLink = document.getElementById("linkToAnimal"); Change the object’s: –HTML properties domLink.href = "cat.html"; –CSS properties domLink.style.backgroundColor = "blue"; Register event handler domButton.addEventListener(“click”, changeLink)

Cash Register Example Total money: $0.00 $0.05 $0.10 $0.25

Exercise #1 – Change this code to make the element have a large font when you move the mouse over it. Bigger Welcome to my page!

Form Validation Example <form method=“post" onsubmit="return confirmSubmit()" action=" > Last name: Number attending(1-100): <input type="text" name="numAttend" id="numAttend" onblur="return checkAttending()" />

//check if last name is filled out function checkLastName(){ var lastNameDOM = document.getElementById("lastName"); var lastNameError = document.getElementById("lastNameError"); var lastName = lastNameDOM.value; //something in the last name field if (lastName){ lastNameError.innerHTML = ""; return true; } //nothing in the last name field else{ lastNameError.style.color = "red"; lastNameError.innerHTML = "*Please fill in the last name"; return false; } // Returns true if the number of attending is okay function checkAttending() { var numDOM = document.getElementById("numAttend"); var numAttendError = document.getElementById("numAttendError"); var numAttend = numDOM.value; if ( (numAttend >= 1) && (numAttend <= 100) ){ numAttendError.innerHTML = ""; return true; } else { numAttendError.style.color = "red"; numAttendError.innerHTML = "*Attendance: Please enter a value between 1 and 100."; return false; }

// Asks user to confirm submission, returns true if ok function confirmSubmit() { if (!checkAttending() || !checkLastName()) return false; if (window.confirm("Are you sure you want to submit?")) return true; else return false; }

All Kinds of Events onblur onfocus onchange onclick ondblclick onload ( only) onmousedown, onmouseup, onmouseout, onmouseover, onmousemove onselect (, only) onsubmit ( only) onunload ( only)

Exercise #2 – Modify so that clicking on the button changes target of element to “dog.html” Change Link See some animals!

Exercise #3 – Write a form to read in a password from the user in two boxes. When they submit the form, proceed only if the passwords are the same.