JavaScript Forms Form Validation Cookies CGI Programs.

Slides:



Advertisements
Similar presentations
HTML Forms. collect information for passing to server- side processes built up from standard widgets –text-input, radio buttons, check boxes, option lists,
Advertisements

WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
The Web Warrior Guide to Web Design Technologies
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
Supplement Creating Forms. Objectives Show how forms are used How to create the Form element HTML elements used for creating input fields.
HTML and XHTML Controlling the Display Of Web Content.
Chapter 7 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 7 Sebesta: Programming the World Wide Web.
Forms Review. 2 Using Forms tag  Contains the form elements on a web page  Container tag tag  Configures a variety of form elements including text.
Information Technology Center Hany Abdelwahab Computer Specialist.
USER INTERACTIONS: FORMS
Using Entities & Creating Forms Jill R. Sommer Institute for Applied Linguistics Kent State University.
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
Forms, Validation Week 7 INFM 603. Announcements Try placing today’s example in htdocs (XAMPP). This will allow you to execute examples that rely on PHP.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
CST JavaScript Validating Form Data with JavaScript.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
CP476 Internet Computing JavaScript and HTML1 1.JavaScript Execution Environment The JavaScript Window object represents the window in which the browser.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript forms.
JavaScript Form Validation
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.
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
Forms and Form Controls Chapter What is a Form?
HTML Forms/Events (Instructor Lesson) The Event model HTML Forms Custom Events 1.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
JavaScript - Document Object Model. Bhawna Mallick 2 Unit Plan What is DOM and its use? Hierarchy of DOM objects. Reflection of these objects in an HTML.
Chapter 3 Using Validation Controls. What is a Validation Control? A control that validates the value in another control Renders as an HTML tag with an.
1 Forms A form is the usual way that information is gotten from a browser to a server –HTML has tags to create a collection of objects that implement this.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Internet / Intranet Fall 2000 Class 7. Brandeis University Internet/Intranet Spring Class 7 Agenda Project / Homework Discussion Forms Validating.
Internet / Intranet CIS-536 Class 7. 2 HTML Forms A Method to Allow Users to Pass Information to a CGI Script Forms Allow Information to Be Entered Via:
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
JavaScript, Fourth Edition
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
Copyright ©2005  Department of Computer & Information Science Introducing DHTML & DOM: JavaScript & Forms.
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
CSC 2720 Building Web Applications HTML Forms. Introduction  HTML forms are used to collect user input.  The collected input is typically sent to a.
Chapter 8 Cookies And Security JavaScript, Third Edition.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Using Client-Side Scripts to Enhance Web Applications 1.
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.
Regular Expression (continue) and Cookies. Quick Review What letter values would be included for the following variable, which will be used for validation.
Website Development with PHP and MySQL Saving Data.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
7 Chapter Seven Client-side Scripts. 7 Chapter Objectives Create HTML forms Learn about client-side scripting languages Create a client-side script using.
Lecture 10 JavaScript: DOM and Dynamic HTML Boriana Koleva Room: C54
HTML Forms. Slide 2 Forms (Introduction) The purpose of input forms Organizing forms with a and Using different element types to get user input A brief.
Netprog 2002 CGI Programming1 CGI Programming CLIENT HTTP SERVER CGI Program http request http response setenv(), dup(), fork(), exec(),...
HTLM Forms CS3505. Form Handling in Browser html User Files out form WEbBROWSErWEbBROWSEr User read response submit Get URL?input html Get file html script.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
Starting BBEdit or Notepad and Opening the HTML File Start BBEdit or Notepad Select Open from the File Menu Open survey1.htm from the Public Folder.
Event Handling. Objectives Using event handlers Simulating events Using event-related methods.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
HTML Forms.
Copyright (c) 2004 Prentice-Hall. All rights reserved. 1 Committed to Shaping the Next Generation of IT Experts. Project 6: Creating XHTML Forms Kelly.
JavaScript Event Handlers. Introduction An event handler executes a segment of a code based on certain events occurring within the application, such as.
CIS 228 The Internet 12/6/11 Forms and Validation.
Lesson 5 Introduction to HTML Forms. Lesson 5 Forms A form is an area that can contain form elements. Form elements are elements that allow the user to.
HTML Structure II (Form) WEEK 2.2. Contents Table Form.
Ashima Wadhwa Java Script And Forms. Introduction Forms: –One of the most common Web page elements used with JavaScript –Typical forms you may encounter.
Chapter 5 Validating Form Data with JavaScript
In this session, you will learn to:
How to Write Web Forms By Mimi Opkins.
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.
Presentation transcript:

JavaScript Forms Form Validation Cookies CGI Programs

What JavaScript can do  Control document appearance and content  Control the browser  Interact with user  Interact with forms  Validate user input  Use cookies

HTML Forms  is a block-level element in the body of your HTML page  A form element can contain text input boxes, buttons, checkboxes, pull-down menus and images  Your document can have multiple form elements  A special button called Submit is used to send the form data to the server

JavaScript and Forms  With a server-side program, an HTML form needs a submit button  With JavaScript, you can react to events of individual input elements.  For some types of tasks, you may never need to submit at all.

Form Objects  An HTML form is represented in JavaScript by a Form object  document.forms[] is an array containing all the forms in the document  Each form object has an elements[] attribute which is an array of input elements document.forms[i].elements[j]  A name attribute in the tag allows you to access the elements by name

Form Objects  Form methods include submit() and reset()  Submit and Reset buttons trigger onsubmit and onreset respectively  onsubmit and onreset handlers invoked just before corresponding method is called  If a handler returns false, the corresponding submit() or reset() method will not be invoked

Form Elements  Use the tag to create controls  type="input-type" needed to specify which type of control  name attribute needed to identify the element  There are special tags for, and

Form Elements and Events ObjectHTMLEvents Button onclick Checkbox onclick Radio onclick Select onchange Option - belongs to Select object Text onchange Password(input type="password">onchange Textarea onchange

Form Elements and Events ObjectHTMLEvents FileUpload onchange Hidden none Reset onclick Submit onclick

Names in Forms  If a form is to be submitted to a server side program, the name attribute of every element must be set  Within the javascript code, you can use the name of a form or form element instead of indexing into the corresponding array  For the form defined by  …  document.everything and document.forms[0] are equivalent ways to refer to the form

Properties of Form Elements  type - read only  form - read only reference to form element is part of  name - name that can be used to refer to the element  value - string sent to web server on submission  text entered by user for text and textarea  text displayed on a button  string set in HTML code for radio and chechbox

Event Handlers for Form Elements  onclick - triggered by mouse click  onchange - triggered by changing a value  onfocus - triggered when element receives focus  onblur - triggered when element loses focus

Validation  Check that all required fields have data e.value==null || e.value==""  Check the format of fields that contain information like addresses, URLs, phone numbers, …  Use the RegExp class to create patterns var pattern = /(\d{3}) \d{3}-\d{4}/  Use an alert to display error messages

Cookies  A cookie is a small amount of named data stored by the browser and associated with a particular web site  provide a way of saving state of a web page  last for current session by default  Server-side programs use cookies  JavaScript can manipulate cookie data

Cookie Attributes  name - each cookie has a name  value - value associated with the cookie  expires - cookies are transient unless this is set  path - web page(s) with which cookie is associated  domain - allows cookie to be available to different web servers  secure - Boolean attribute that specifies whether cookies must be transmitted over a secure (https) connection

Storing Cookies  Creating a transient cookie document.cookie = "version=" + escape( document.lastModified);  escape encodes characters that aren't allowed in the cookie  Storing other attributes with a cookie  Use semicolon to separate attribute=value pairs document.cookie = "version=" + escape(document.lastModified) + "; expires=" + nextYear.toGMTString();

Reading Cookies  document.cookie returns a string containing all the cookies for the document.  name=value pairs separated by semicolons  value does not include attributes

CGI Programs  Common Gateway Interface  A protocol for interfacing external programs to a web server  Environment variables are used to store information that needs to be passed from the web server to the CGI program which runs as a separate process.

Environment Variables NameValue DOCUMENT_ROOTroot directory of server HTTP_COOKIEcookie data REQUEST_METHODPOST or GET QUERY_STRINGform data passed to program

Request Method POST  more secure  data is sent to the program as an input stream (STDIN) GET  data is encoded into the URL that accesses the cgi program  data is stored in the QUERY_STRING environment variable data format is name=value&name=value&name=value

URL Encoding  Letters and digits are left alone  Spaces become +  All other characters are replaced by %hh where hh is the hexadecimal ASCII code

cgi programs on onyx  On onyx, you need to put your CGI programs into a directory called cgi-bin which is under your public_html directory  Programs need to have the.cgi extension  Programs need to be executable