CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript forms.

Slides:



Advertisements
Similar presentations
Working with Forms. how are forms manipulated? the document object contains an array of forms objects, one for each form, in document order –forms[] any.
Advertisements

Computer and Communication Fundamental Basic web programming Lecture 8 Rina Zviel-Girshin.
JavaScript and the DOM Les Carr COMP3001 Les Carr COMP3001.
1 Topic 6 Processing Form Input. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction Form.
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
HTML and XHTML Controlling the Display Of Web Content.
Web Database Programming Input Validation. User Input on the Web Web browser built-in mechanisms –HTML Forms HTTP POST method –Hyperlinks HTTP GET method.
Forms cs105. More Interactive web-pages So far what we have seen was to present the information. (Ex: tables. Lists,….). But it is not enough. We want.
Chapter 7 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 7 Sebesta: Programming the World Wide Web.
JavaScript Forms Form Validation Cookies CGI Programs.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
Lesson 2 Event Handling. Object Event Handlers Most of the objects that make up the Document Object Model respond to asynchronous, user generated events.
Lesson 8 Creating Forms with JavaScript
CST JavaScript Validating Form Data with JavaScript.
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 What is a form.
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.
JavaScript - a Brief Introduction Anupriya. What is JavaScript Object based (not object oriented) programming language –very limited object creation –a.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
Copyright ©2005  Department of Computer & Information Science Introducing DHTML & DOM: JavaScript & Forms.
JavaScript II ECT 270 Robin Burke. Outline JavaScript review Processing Syntax Events and event handling Form validation.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
© 2000 – All Rights Reserved - Page 1 Introduction to JavaScript Programming Part Two.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 16 – Dynamic HTML: Event Model Outline 16.1Introduction 16.2Event ONCLICK 16.3Event ONLOAD.
1 Forms and Form elements CSD 340 McCoey. 2 Form Object Properties action Usually a call to a server elements encoding method post or get target Methods.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
CNIT 133 Interactive Web Pags – JavaScript and AJAX How to run JavaScript?
PHP Form Introduction Getting User Information Text Input.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
Lecture 10 JavaScript: DOM and Dynamic HTML Boriana Koleva Room: C54
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.
Chapter 19 Creating and Processing HTML Forms. How HTML Forms Transmit Data name1=value1&name2=value2...&nameN =valueN GET or POST GET, an HTTP GET request,
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
Form Components and Elements
Thursday, August 6 th, 2015 Instructor: Craig Duckett Event Handling.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 16 – Dynamic HTML: Event Model Outline 16.1Introduction 16.2Event ONCLICK 16.3Event ONLOAD.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
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.
HTML FORMS The TEXT Object Presented By: Ankit Gupta.
Week 10: HTML Forms HNDIT11062 – Web Development.
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
JavaScript II ECT 270 Robin Burke. Outline Functions Events and event handling Form validation.
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.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
1 Web Engineering Forms Lecture 05. FORMS Its how HTML does interactivity. There are quite new feature in HTML5. But the fundamental idea does not change.
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.
CIS 228 The Internet 12/6/11 Forms and Validation.
HTML Tables Tables are defined with the tag. A table is divided into rows (with the tag), and each row is divided into data cells (with the tag). td stands.
Chapter 14 The HTML Tag
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Handling events from DOM objects.
Methods and Object Information. Some Document Methods.
Chapter 4 Java Script – Part2. 2 Location object Properties Properties href – whole path will be displayed. ex: window.location.href ( see example 11)
Chapter 5 Validating Form Data with JavaScript
In this session, you will learn to:
Forms Web Design Ms. Olifer.
JAVASCRIPTS AND HTML DOCUMENTS
Creating Form Elements
FORM OBJECT When creating an interactive web site for the Internet it is necessary to capture user input and process this input. Based on the result of.
© 2015, Mike Murach & Associates, Inc.
JavaScript and Forms Kevin Harville.
JavaScript and Ajax (JavaScript Events)
Presentation transcript:

CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript forms

Agenda My Web Site: (download syllabus, class notes). JavaScript forms. Form samples.

Forms and Form Elements In JavaScript programs, the emphasis is not on form submission and processing but instead on event handling. A form and all input elements in it have event handlers that JavaScript can use to respond to user interactions within the form. With server-side programs, an HTML form is not useful unless it has a Submit button. With JavaScript, on the other hand, a Submit button is never necessary. With JavaScript event handlers, a form can have any number of push buttons that perform various actions when clicked.

The Form Object Form objects are available as elements of the forms[ ] array, which is a property of the Document object. You can refer to the last form in a document: document.forms[document.forms.length – 1] The most interesting property of the Form object is the element[ ] array, which contains JavaScript objects (of various types) that represent the various input elements of the form. document.forms[1].elements[2] // 3 rd element 2 nd form The remaining properties of the Form object are of less importance. The action, encoding, method, and target properties correspond directly to the action, encoding, method, and target attributes of the tag.

The Form Object (continue…) The JavaScript Form object supports two methods, submit() and reset(). Invoking the submit() method of a Form submits the form Invoking reset() resets the form elements. The Form object provides the onsubmit event handler to detect form submission and the onreset handler to detect form resets. <form … onreset="return confirm('Really erase All data and start over? '); " >

Defining Form Elements HTML form elements allow you to create simple user interfaces for your JavaScript programs HTML form elements:  button  checkbox  file  hidden  option  password  radio  reset  select  submit  text  textarea

Naming Forms and Form Elements Every form element has a name attribute that must be set in its HTML tag if the form is to be submitted to a server-side program. For example, a form is defined with this tag: You can refer to the Form object as: document.everything You will find this more convenient: document.forms[0] Using a form name makes your code position- independent.

Form Element Event Handlers Most form elements support most of the following event handlers:  onclick  onchange  onfocus  onblur Within the code of an event handler, the this keyword refers to the document element that triggered the event. Since all form elements have a form property that refers to the containing form, the event handlers of a form element can always refer to the Form object as this.form.

Form – change background color sample function changeColor(color) { document.getElementById('x').style.backgroundColor=color; } This example demonstrates how to change the background color of an input field. Mouse over the three colored table cells, and the input field will change background-color:

Form – change text color sample function changeColor(color) { document.getElementById('x').style.color=color; } This example demonstrates how to change the text color of an input field. Mouse over the three colored table cells, and the text will change color:

Form – checkbox sample function makeCheck(thisForm) { for (i = 0; i < thisForm.option.length; i++) { thisForm.option[i].checked=true; } function makeUncheck(thisForm) { for (i = 0; i < thisForm.option.length; i++) { thisForm.option[i].checked=false; } Apples Oranges Bananas Melons