Forms Most application interface with users through a Graphical User Interface (GUI) GUI objects are components that allow users to enter information.

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

Essentials for Design JavaScript Level One Michael Brooks
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Introduction to JavaScript
Tutorial 6 Creating a Web Form
The Web Warrior Guide to Web Design Technologies
JavaScript Forms Form Validation Cookies CGI Programs.
Creating Web Page Forms. Objectives Describe how Web forms can interact with a server-based program Insert a form into a Web page Create and format a.
Tutorial 6 Working with Web Forms
Computer Science 103 Chapter 4 Advanced JavaScript.
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Creating Web Page Forms
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
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.
Javascript and the Web Whys and Hows of Javascript.
4-Sep-15 HTML Forms Mrs. Goins Web Design Class. Parts of a Web Form A Form is an area that can contain Form Control/Elements. Each piece of information.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
XP Tutorial 6New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Creating Web Page Forms Designing a Product Registration Form Tutorial.
DAT602 Database Application Development Lecture 14 HTML.
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.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Project Four Forms Discuss form processing Describe the difference between client-side and server-side form processing Add a horizontal rule to a Web page.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
Generations of Programming Languages First generation  Machine Language Second Generation  Assembly Language Third Generation  Procedural language such.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
10 Adding Interactivity to a Web Site Section 10.1 Define scripting Summarize interactivity design guidelines Identify scripting languages Compare common.
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
1 JavaScript in Context. Server-Side Programming.
Tutorial 10 Programming with JavaScript
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
JavaScript. During the last lecture We looked at the utility of forms on Web pages We found out about the various components that are used in a form We.
HTML Forms.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
ITCS373: Internet Technology Lecture 5: More HTML.
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
7 Chapter Seven Client-side Scripts. 7 Chapter Objectives Create HTML forms Learn about client-side scripting languages Create a client-side script using.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
Introduction to JavaScript CS101 Introduction to Computing.
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
©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.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
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.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
Tutorial 6 Creating a Web Form
HTML Structure II (Form) WEEK 2.2. Contents Table Form.
XP Tutorial 6New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
Chapter 5 Validating Form Data with JavaScript
WEB PROGRAMMING JavaScript.
Lesson 6: Web Forms.
Presentation transcript:

Forms Most application interface with users through a Graphical User Interface (GUI) GUI objects are components that allow users to enter information. They are largely standard across many modern applications A form is a collection of GUI objects that work together to interact with a user and accomplish a task.

Examples of GUI Components Text  Text area  Clickable Components Radio button  Check box  General Buttons  Drop down menu  Reset and submit 

The Input Tag math yes Use this tag to create most of the GUI components Note: hidden components are useful for adding data to a form that a user does not have to enter, like time of day.

Creating a group of radio buttons yes no maybe Notes 1.Users can select ONLY one of a group of related ratio buttons. In the above example, clicking on 'no' will deselect 'yes' 2.The name attribute ties radio buttons together –Related radio buttons set the name attribute value to the same text –The above example uses the attribute value: 'group'. 3.The value attribute is needed to submit properly

Creating a Group of Check Boxes math english science Notes 1.You can click more than one check box. 2.The name attribute can have different values

Creating a Drop Down Menu coke Pepsi Dr. Pepper Notes 1.The tag must have a name attribute, or it will not submit 2.You need the value attribute for proper form submission. coke Pepsi Dr. Pepper

Text areas and text components Notes 1.Text components only allow users to enter one row of information; the size attribute specifies the width of the component 2.Text areas allow multiple rows using the rows. The cols attribute specifies the width of each row. 3.Text area components use the tag, with its closing counterpart 4.The value attributes for these components contains the data the user types.

Constructing a form in HTML... Insert all your form elements here... Use the form tag makes all of the GUI elements are grouped together in a single unit

Submitting Forms <form method="post" enctype="text/plain" >... Put all your GUI components here... Notes 1.Forms can submit by (above example), to a server side program, or be processed locally with JavaScript 2.The reset button clears all user input; the submit button sends the form for processing 3.IMPORTANT: Any component missing a name attribute WILL NOT SUBMIT

Submitting to Server Side Programs Advantages over submission 1.It does not matter if users have set up 2.Some browsers output warning messages that will discourage users from submitting 3.Submits automatically without bringing up the program Another consideration 1.text/plain is not encrypted data. There are no security protections. For e-commerce applications, it is important to encrypt data so critical information like social security, and credit card numbers are not revealed to programs listening for malevolent reasons

Common Gateway Interface (CGI) 1.GUI components submit as name=value pairs of data submits as: myGroup=myValue Every letter has a hexadecimal character code (ASCII). CGI replaces some characters with their ASCII codes. Spaces with %20, colon with %3A, and slashes with %2F. The plus is for lines of text area components 2.The & character is a delimiter between pairs 3.The following is a CGI example: name=dan&group=yes&interest=high&area=oregon&info=co ol&20site++&site=http%3A%2F%2Fcs.sou.edu/~harveyd 3. programs show the CGI in a more readable form CGI is the protocol for sending Web information between computers

Processing Forms Locally 1.HTML can display forms. It cannot process them. 2.JavaScript can process forms locally 3.Advantages of local processing Lesson Internet traffic Reduce the load on server computers Greater security, since the local computer is not seen by other computers Ensure that data sent to servers is correct before submitting We need JavaScript!!

Important Reminders Regarding GUI Components Field without a name attribute will NOT submit to a server or to –Will Submit: –Will not submit: Radio buttons must have a value attribute for servers to parse correctly. – –The first will submit CGI: rads=myRadio, the second will submit rads=on. The server will not know which one of a group was selected. All radio buttons of a group must have their name attributes set to the same thing. Otherwise, they will work like check boxes.

JavaScript can do more JavaScript begins where HTML leaves off How? –Perform calculations –Interacts with the user –Adds to the browsing experience of the user –Manipulates and alter the HTML tags, and what displays Examples –Roll over images –Games –Process Forms at the client side –Quotes of the day –Slide Shows –Today’s Date –Calculators –Online quizzes

Programming Languages First Generation: Machine Language –All ones and zeroes ( could be an instruction) Second Generation: Assembly Language –One line of symbols for each machine language instruction –Examples: add ax, 14 or mov bx, 6 or cmp ax, bx High Level: General Purpose Imperative (Java) –More readable to most human beings –Tell the computer step by step what to do and how to do it Scripting: interpretive languages –Designed for a special purpose –JavaScript’s purpose is to work with HTML Declarative: English like (SQL) –Special purpose –Tell the computer what to do, how is it’s problem Note: Visual Basic falls between high level and declarative

Basic Control Structures Sequence Structure 1.Do this 2.Do that 3.Do something else 4.Do that again 5.Do another thing Condition or Transfer Structure IF this THEN do that ELSE do the other thing Iteration or Loop WHILE this true DO something DO something UNTIL this false FOR many times DO something All computer processing done this way

JavaScript verses Java Java (General Purpose) –Create any computer applications –Create applets to work in their own browser window area JavaScript (Special Purpose) –Mini-language that only executes in a browser –Initial purpose: Validate client-side forms –Present purpose: Enhance HTML capabilities –Netscape’s original name: LiveScript –Syntax is very similar to Java These languages have similar syntax, but are very different

Getting Into JavaScript 1.In-line Script –Use special event attributes, like onclick, onmouseover, onload, and many more 2.Document Level Script –Use the tag –This differs from CSS in that the tag can go anywhere in a document 3.External Script –Use the tag and refer to an external javascript file. –This method is preferred because JavaScript will often make it impossible to validate the Web pages. Similar concepts to CSS style sheets

Starting a Script The Script tag (To display a message in a dialog box) alert("HelloWorld!"); We need the type attribute (identifies the scripting language) –perlScript, vbScript – Other client side scripts –php, asp – Other server side scripts Script to an external file Older deprecated version of the script tag. Do not use!! Examples

Words of Caution Browsers try to do something when HTML syntax is wrong. They will just ignore what they do not understand Browsers ignores CSS styles that it does not understand. Browsers will ignore all JavaScript once there is even one error in syntax. –Be very careful about exact syntax, and save yourself lots of grief –If your script does not work, go to Firefox tools, and click on Error Console. It will point out the line of the error

A JavaScript Example alert("HelloWorld!"); JavaScript Test alert("Who is there?"); First alert done alert("I\'m back!"); All done Key Definition: A string is a sequence of letters Note: Always end JavaScript statements with a semicolon Note: Always enclose strings of text with single or double quotes Note: The \' illustrates a break sequence (we really mean ').

JavaScript with Check Boxes Which Languages do you know? JavaScript<input type="checkbox" onclick="alert('I know JavaScript');" /> HTML<input type="checkbox" onclick="alert('I know HTML');"/> XML<input type="checkbox" onclick="alert('I know XML');"/> Note: The JavaScript instruction executes when the user clicks the checkbox. Question: Why does the alert command use single quotes?

JavaScript and Radio Buttons Select a Soda Coke<input type="radio" name="group" onclick="alert('It\'s the real thing');" /> Pepsi<input type="radio" name="group" onclick="alert('the pepsi generation');"/> Dr. Pepper<input type="radio" name="group" onclick="alert('Be a pepper');"/> Question: The name attribute is the same for all radio buttons. Why? Question: Why does the alert commands use single quotes? Note: The \' is an escape sequence (we want the ' to be part of the string)

JavaScript and submitting forms <form method="post" enctype="text/plain" action= onsubmit="alert('I\'ll not submit'); return false;" > Notes 1.Note the single and double quotes and the escape sequence 2.Note the second statement. It stops the browser from submitting the form to the server. 3.JavaScript has a vocabulary of reserved words, and we will use more of them later. The word 'return' is our first. All JavaScript reserved words are lower case.

Review Questions What is GUI stand for? How do you create a drop down menu? What is the principle difference between text and text area components? What are the three ways a form can be processed? What is a hidden form element? When would it be useful? What is the disadvantages to submitting forms using the interface? Why do radio buttons need the same name attribute values, and unique value attribute values? What is CGI? Why are tables often combined with forms? What is JavaScript? What is an escape sequence? What does alert do in JavaScript? How do you execute in-line JavaScript? How do you link to an external JavaScript file? Why is it wrong to use the language attribute?