Capturing user input: Using HTML FORMs CS4320 got here on 27/11/2003.

Slides:



Advertisements
Similar presentations
1 Introduction to HTML II อุทัย เซี่ยงเจ็น สำนักวิชาเทคโนโลยีสารสนเทศ และการสื่อสาร มหาวิทยาลัยนเรศวร พะเยา.
Advertisements

JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
NAMEd anchors Enabling users to jump to specific points within Web documents.
Capturing user input: Using HTML FORMs User input Up till now, our HTML documents have all been directed at outputting information to the user However,
JavaScript Forms Form Validation Cookies CGI Programs.
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.
Forms Describe common uses of forms on web pages
The conditional statement General form: if ( ) { consequent-action-list } Actual Example: if (document.getElemendById(‘name’).value= ='') { alert(‘Name.
Other types of input element There are some types of input element that we have not considered: –type='image’ –type='hidden’ We will delay dealing with.
NAMEd anchors Enabling users to jump to specific points within Web documents.
1 CS101 Introduction to Computing Lecture 12 Interactive Forms (Web Development Lecture 4)
XHTML Forms for Data Collection and Submission Chapter 5.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
Chapter 10 Form Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D 1.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
CO1552 Web Application Development HTML Forms. Websites can be made more interactive by providing facilities for users to provide data To get user entered.
Forms and Form Controls Chapter What is a Form?
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.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
1 VU. 2 CS101 Introduction to Computing Lecture 15 More on Interactive Forms (Web Development Lecture 5)
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
1 Essential HTML coding By Fadi Safieddine (Week 2)
Introduction to Programming the WWW I CMSC Summer 2004 Lecture 6.
CSC 2720 Building Web Applications HTML Forms. Introduction  HTML forms are used to collect user input.  The collected input is typically sent to a.
Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and check boxes using HTML Add a pull-down.
Lecture # 6 Forms, Widgets and Event Handling. Today Questions: From notes/reading/life? Share Personal Web Page (if not too personal) 1.Introduce: How.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
HTML Forms.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
LOGO FORMs in HTML CHAPTER 5 Eastern Mediterranean University School of Computing and Technology Department of Information Technology ITEC229 Client-Side.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
Week 9 - Form Basics Key Concepts 1. 1.Describe common uses of forms on web pages 2.Create forms on web pages using the form, input, textarea, and select.
ITCS373: Internet Technology Lecture 5: More HTML.
Dynamic web content HTTP and HTML: Berners-Lee’s Basics.
TJ 3043 – Web Application Development HTML Form. 2.0 Forms A form is the usual way to communicate information from a Web browser to a server HTML has.
Creating Web Page Forms. Introducing Web Forms Web forms collect information from users Web forms include different control elements including: –Input.
1 CSC317/318 INTERNET PROGRAMING / DYNAMIC WEB APPLICATION DEVELOPMENT Siti Nurbaya Ismail Faculty of Computer & Mathematical Sciences, Universiti Teknologi.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
1 Review of Form Elements. 2 The tag Used in between tags.  Form elements(text control, buttons, etc.. ) goes here. OR  Form elements(text control,
Introduction to JavaScript CS101 Introduction to Computing.
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.
TJ 3043 – Web Application Development HTML Form. 2.0 Forms - A form is the usual way information is gotten from a browser to a server - HTML has tags.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
Web Page Design Forms! Website Design. Objectives What forms can do The Attributes of the form tag Using Textboxes Textareas Checkboxes Radio buttons.
Copyright © Texas Education Agency, All rights reserved.1 Web Technologies Website Forms / Data Acquisition.
©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.
Netprog CGI and Forms1 CGI and Forms A detailed look at HTML forms.
HTML Forms. A form is simply an area that can contain form fields. Form fields are objects that allow the visitor to enter information - for example text.
Since you’ll need a place for the user to enter a search query. Every form must have these basic components: – The submission type defined with the method.
ASSIGNMENT POINTS DUE DATE: Monday NOV 30 JAVASCRIPT, INPUT VALIDATION, REGEX See 2 nd slide for Form See 3 rd next slide for the required features.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
INTERNET APPLICATIONS CPIT405 Forms, Internal links, meta tags, search engine friendly websites.
Web Forms. Web Forms: A form allows our web visitors to submit information to us. Some examples uses for forms are to let the web user contact us, fill.
HTML Structure II (Form) WEEK 2.2. Contents Table Form.
FORMS Explained By: Jasdeep Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
Objectives Design a form Create a form Create text fields
Validation and Building Small Apps
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.
Forms, cont’d.
Web Development & Design Foundations with H T M L 5
Unit 5 Create Forms.
Web Forms.
Presentation transcript:

Capturing user input: Using HTML FORMs

CS4320 got here on 27/11/2003

User input Up till now, our HTML documents have all been directed at outputting information to the user However, some applications of HTML involve inputting information from the user –possibly, to tailor future output to the user –or to populate a database of user data

Example On the next slide, the web page shown contains a form that the user may complete in order to send some information to a club that he wants to join The form contains –two input boxes that the user can fill in and – a submit button that he can click on in order to send his data to the club’s web site

Say he submits the data below:

He gets the personalized reply below from the web site:

How this is done: There are two parts to what happens: –When the user clicks on the submit button, the data on the form is sent to a “server-side” program at the club’s web-site –The server-side program reads the data and writes a special HTML page which is sent back to the user’s browser We will not consider server-side programming at this stage -- it is a very large topic! We will focus on client-side activity

Specifying the form that the user fills in: In HTML, a form specification is delimited by two tags: and Among the attributes of a tag, two are especially important: –the ACTION attribute specifies a URL for the program to which the data given by the user is to be sent –the METHOD attribute specifies the way in which the data are to be sent to this program

Example The (partial) form specification below says that the data must be sent by a method called “post” to a program called appln.cgi in the cgi-bin directory on the server where the document containing the form is stored ….

METHODs for sending data There are two main METHODs: –POST –GET You can ignore the details of these methods for now –they concern how the data is encoded when being transmitted across the Internet –you just need to remember that, in both methods, the data are sent in the form of equations of the form = for example name=Bill We will use the POST method in our examples

Grouping the elements of a form As well as user-inputs, we can have headings etc. on a form It is usually convenient to organize the user- inputs into groups of related elements Such a group is called a FIELDSET: –a FIELDSET is delimited by two tags: and Each FIELDSET can have a LEGEND (a title) which helps the user to understand the form

Example The form below has one heading and two fieldsets Each fieldset has a legend which is printed in the border around the fieldset

Some more detail from the spec: Membership Application Form Contact Information …... Form Submission …...

User-input elements Several different kinds of user-input element are possible on a form: BUTTON, INPUT, SELECT, TEXTAREA Only two main kinds are used on this form, –the INPUT element and –the BUTTON element

INPUT elements

INPUT elements of TYPE=text INPUT elements whose TYPE attribute have the value text are rendered as boxes in which the user can type a sequence of characters INPUT elements whose TYPE attribute have one of the other values are rendered differently

Some more detail... Membership Application Form Contact Information What is your name? Please enter your address: Form Submission …...

The BUTTON element BUTTON elements are rendered as button on which the user can click the mouse a BUTTON element is delimited by a tag and a tag The text between these tags is engraved on the button The tag has a TYPE attribute which specifies what should happen when the user clicks on the button: TYPE=submit causes the user’s input to be sent to the program indicated in the FORM’s ACTION TYPE=reset causes the user’s input to be cleared so that he may correct some mistakes TYPE=button causes a client-side event-handler to be executed

The complete form specification: Membership Application Form Contact Information What is your name? Please enter your address: Form Submission Submit application

Stylesheet specification of FORMs rendering FORMs, of course, can be handled in stylesheets, using the usual features Example: FORM {BACKGROUND-COLOR : red; PADDING : 0.2in} FIELDSET {PADDING : 0.2in}

Complete Docum’nt Spec (Part I) Membership Application Form FORM {BACKGROUND-COLOR : red; PADDING : 0.2in} FIELDSET {PADDING : 0.2in} If you want to join our club, complete the form below and we will get back to you.

Complete Docm’nt Spec (Part II) Membership Application Form Contact Information What is your name? Please enter your address: Form Submission Submit application

Using a BUTTON element of TYPE=button On the next slide, there is an extra button element It is of TYPE=button because it is purely to enable a Javascript program to be executed so that a client-side check of the user’s data can be performed before the data are transmitted acros the Internet

Revised form specification: Membership Application Form Contact Information What is your name? Please enter your address: Form Submission Check application Submit application

Buttons are too close:

Improve this in stylesheet FORM {BACKGROUND-COLOR : red; PADDING : 0.2in} FIELDSET {PADDING : 0.2in} BUTTON {MARGIN : 0.1in}

What should happen when the ‘checkApplication’ function is executed If either of the INPUTs is still empty, a warning window should pop-up

Writing the event-handler We need to be able to refer to the INPUTs on the form in order to see if they are empty or not Each INPUT has a NAME attribute so you might think that we could refer to the INPUTs directly by these NAMEs However, Javascript requires that we refer to a FORM and then to the INPUTs on the form So the FORM must have a NAME too

Further revised specification: Membership Application Form Contact Information What is your name? Please enter your address: Form Submission Check application Submit application

Specifying the event-handling function We insert a SCRIPT containing the function definition in the document HEAD: function checkApplication() {if (applicationForm.name.value=='') { alert("Name is empty") } ; if (applicationForm. .value=='') { alert(" address is empty") } } It contains two conditional statements each of which checks whether one INPUT is empty and, if so, produces an alert saying so

Cs 3314 got here on 1 nov 2004