Creating and Building Websites

Similar documents
HTML Tables and Forms. Outline. Review. Review. Example Demo/ Walkthrough. CS 418/518 Web Programming Spring Tables to Display Data"

Spring 2014 Interim. HTML forms

HTML Forms. By Jaroslav Mohapl

The Hypertext Markup Language (HTML) Part II. Hamid Zarrabi-Zadeh Web Programming Fall 2013

Chapter 1 FORMS. SYS-ED/ Computer Education Techniques, Inc.

Row and Column Spans. Homework. Column and Row Span Example (2) Column and Row Span Example. tables: Live Demo. like the following using forms:

Form Overview. Form Processing. The Form Element. CMPT 165: Form Basics

Figure 1 Forms category in the Insert panel. You set up a form by inserting it and configuring options through the Properties panel.

Hyperlinks, Tables, Forms and Frameworks

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB

Web Forms. Survey or poll Contact us Sign up for an newsletter Register for an event

1 Form Basics CSC309

Summary 4/5. (contains info about the html)

CSE 154 LECTURE 8: FORMS

Forms, CGI. Objectives

HTML: Fragments, Frames, and Forms. Overview

HTML Form. Kanida Sinmai

Lesson 3. Form By Raymond Tsang. Certificate Programme in Cyber Security

Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM Advanced Internet Technology Lab.

Lecture (03) from static HTML to

core programming HTML Forms Sending Data to Server-Side Programs Marty Hall, Larry Brown

Outline of Lecture 5. Course Content. Objectives of Lecture 6 CGI and HTML Forms

Building Web Based Application using HTML

Forms, CGI. Cristian Bogdan 2D2052 / 2D1335 F5 1

COMP1000 Mid-Session Test 2017s1

COMS 359: Interactive Media

Dynamic HTML becomes HTML5. HTML Forms and Server Processing. Form Submission to Web Server. DHTML - Mouse Events. CMST385: Slide Set 8: Forms

Forms, CGI. HTML forms. Form example. Form example...

DAY 2. Creating Forms

Javascript. UNIVERSITY OF MASSACHUSETTS AMHERST CMPSCI 120 Fall 2010

CS 350 COMPUTER/HUMAN INTERACTION. Lecture 6

Overview of Forms. Forms are used all over the Web to: Types of forms: Accept information Provide interactivity

Web Design and Development ACS Chapter 13. Using Forms 11/27/2018 1

Collecting Information with Forms

CHAPTER 6: CREATING A WEB FORM CREATED BY L. ASMA RIKLI (ADAPTED FROM HTML, CSS, AND DYNAMIC HTML BY CAREY)

Web Programming. Based on Notes by D. Hollinger Also Java Network Programming and Distributed Computing, Chs.. 9,10 Also Online Java Tutorial, Sun.

chapter 7 Interacting with Users Tell me and I will forget. Show me and I will remember. Involve me and I will understand.

CGI Programming. What is "CGI"?

LAB MANUAL SUBJECT: WEB TECHNOLOGY CLASS : T.E (COMPUTER) SEMESTER: VI

Creating Web Pages Using HTML

Web Site Design and Development Lecture 23. CS 0134 Fall 2018 Tues and Thurs 1:00 2:15PM

HTML Tables and. Chapter Pearson. Fundamentals of Web Development. Randy Connolly and Ricardo Hoar

6Lesson 6: Web Forms Objectives

HTML crashcourse. general structure tables forms textfield textarea selectbox listbox hidden field checkbox radiobuttons submit button

HTML forms and the dynamic web

Networking and Internet

Creating a Web Page with HTML

IEEM 230. PHP Basics, Part IV. Objectives of the lab:

cwhois Manual Copyright Vibralogix. All rights reserved.

Chapter4: HTML Table and Script page, HTML5 new forms. Asst. Prof. Dr. Supakit Nootyaskool Information Technology, KMITL

Practice problems. 1 Draw the output for the following code. 2. Draw the output for the following code.

Q1. What is JavaScript?

HTML Forms IT WS I - Lecture 11

COMPUTER APPLICATIONS IN BUSINESS FYBMS SEM II

By the end of this section of the practical, the students should be able to:

D B M G. Introduction to databases. Web programming: the HTML language. Web programming. The HTML Politecnico di Torino 1

CSS Review. Objec(ves. Iden(fy the Errors. Fixed CSS. CSS Organiza(on

Web forms and CGI scripts

HTML 5 Tables and Forms

Controlled Assessment Task. Question 1 - Describe how this HTML code produces the form displayed in the browser.

NETB 329 Lecture 13 Python CGI Programming

CSC Web Technologies, Spring HTML Review

Outline. Introducing Form. Introducing Forms 2/21/2013 INTRODUCTION TO WEB DEVELOPMENT AND HTML

Dreamweaver: Web Forms

<form>. input elements. </form>

Javascript. UNIVERSITY OF MASSACHUSETTS AMHERST CMPSCI 120 Fall 2010

BOOTSTRAP FORMS. Wrap labels and controls in a <div> with class.form-group. This is needed for optimum spacing.

PHP with MySQL: What you need to know Chapter 3. This section is on using PHP script tags appropriately in your PHP program.

jquery - Other Selectors In jquery the selectors are defined inside the $(" ") jquery wrapper also you have to use single quotes jquery wrapper.

Web Technologies - by G. Sreenivasulu Handout - 1 UNIT - I

Web technologies. Web. basic components. embellishments in browser. DOM (document object model)

HTML and JavaScript: Forms and Validation

Javascript, Java, Flash, Silverlight, HTML5 (animation, audio/video, ) Ajax (asynchronous Javascript and XML)

Dynamic Form Processing Tool Version 5.0 November 2014

Chapter 3 HTML Multimedia and Inputs

USQ/CSC2406 Web Publishing

Information and Communication Technology (ICT) CBSE Board Question Paper 2018 Solution

INTRODUCTION TO CGI PROGRAMMING By Jumail Bin Taliba, GMM, FSKSM, UTM INTRODUCTION

Advanced HTML 5.1 INTRODUCTION 5.2 OBJECTIVES

Lecture 6: More Arrays & HTML Forms. CS 383 Web Development II Monday, February 12, 2018

HTML. Asst. Prof. Dr. Kanda Runapongsa Saikaew Department of Computer Engineering Khon Kaen University

HTML Element A pair of tags and the content these include are known as an element

WEBD 236 Web Information Systems Programming

Chapter 4 Sending Data to Your Application

HTML Tags Chart. To use any of the following HTML tags, simply select the HTML code you'd like and copy and paste it into your web page.

Creating Forms. Speaker: Ray Ryon

Tag Name Code Example Browser View. <!--This can be viewed in the HTML part of a document--> <a href=" Visit Our Site</a>

SilkTest 2009 R2. Rules for Object Recognition

HTML What is HTML Hyper Text Markup Language is a computer based language used to create WebPages.

Server-Side Web Programming: Python (Part 1) Copyright 2017 by Robert M. Dondero, Ph.D. Princeton University

Web Focused Programming With PHP

Control Solutions i.candoit, i.board, and Babel Buster SP Web Server CGI Overview (2/2008)

WEB PAGE DESIGN. Structure

PYTHON CGI PROGRAMMING

CITS1231 Web Technologies

Silk Test Object Recognition with the Classic Agent

1.264 Lecture 12. HTML Introduction to FrontPage

Last &me: Javascript (forms and func&ons)

SYBMM ADVANCED COMPUTERS QUESTION BANK 2013

c122sep2914.notebook September 29, 2014

Transcription:

Creating and Building Websites Stanford University Continuing Studies CS 21 Mark Branom branom@alumni.stanford.edu Course Web Site: http://web.stanford.edu/group/csp/cs21 Week 7 Slide 1 of 25

Week 7 Unfinished business Forms What are Forms? Creating a Form Processor Creating an HTML form Week 7 Slide 2 of 25

Forms Forms are Fun!!! They form the basis for interactivity on the World Wide Web. allow visitors to communicate with the page owner guestbooks (where visitors can leave comments viewable to all) allow page owners to gather information about their visitors for online surveys for online exams to purchase supplies/tickets/room reservations Week 7 Slide 3 of 25

Parts of a Form There are two parts to any form: The HTML portion, where the visitor will interact with the webpage The CGI (Common Gateway Interface) program which will process the form. Week 7 Slide 4 of 25

Forms processing Once a user submits the form, the data sent needs to be processed, usually via a CGI program (often written in PERL, PHP, C++, ASP, Visual Basic, or Java). Many CGI scripts are freely available to download and utilize on your server without needing to have much expertise in the programming language: http://www.wired.com/2010/02/perl_tutorial_for_beginners/ http://www.wired.com/2010/02/php_tutorial_for_beginners/ http://github.com/ http://code.google.com/ http://www.cgiscript.net/ http://www.javascript.com/ https://creative.adobe.com/addons Week 7 Slide 5 of 25

HTML part <FORM>: marks the form <INPUT>: tag used to define variables and field types TEXT: single-line textbox PASSWORD: single-line textbox but in hidden text RADIO: radio button single-choice selections CHECKBOX: checkbox button multiple-choice selections RESET: used to reset variables back to default value SUBMIT: used to submit form to the CGI script BUTTON: used to submit form to a JavaScript or other client-side script HIDDEN: used to submit hidden information <TEXTAREA>: tag used for multiple-line textbox <SELECT>: tag used for pull-down menus Week 7 Slide 6 of 25

<FORM> tag Encloses all of the form elements. - contains METHOD and ACTION attributes First, the form needs to know how to send the information to the server. Two methods are available: METHOD="GET" METHOD="POST" Week 7 Slide 7 of 28

METHOD="GET" Most HTML documents are retrieved by requesting a single URL from the server. GET tacks on the information from the form to the end of the URL. Spaces are translated into + sign; if there s more than one variable, they re separated by an & sign: http://www.google.com/search?q=stanford+university&hl=de http://www.google.com/search?q=stanford+university http://www.google.com/search?q=stanford+university&hl=de

METHOD="POST" With the POST method, the information from the form is sent to the CGI script separately from the URL This is the preferred method. It is the method most commonly used in creating forms, as it is less likely to cause problems if there are many variables and data. https://d.sfcu.org/signon/logon.aspx?returnurl=%2f https://d.sfcu.org/signon/logon.aspx?returnurl=%2f

More on <FORM> Second, the form needs to know where to send the information. This is the URL being requested from the form, and is referenced with the ACTION tag. This URL will almost always point to a computer script to decode the form results. ACTION="http://www.company.com/cgi/script.pl" Once you put it all together, your form will usually have the following format: <FORM METHOD="POST" ACTION="http://www.company.com/cgi/script.pl"> [Form input tags and other HTML goes here] </FORM> Notice that this form uses the method POST and sends the input information to a local script named script.pl in the cgi web directory. Week 7 Slide 10 of 25

<INPUT> tag FORM contents consist primarily of INPUT tags, which define the field types and the names of the variables. These INPUT tags allow the visitor to enter information or to select choices. Each INPUT tag is given a TYPE and NAME attributes. These attributes determine what kind of information it contains and the name identifier for the field. This is the syntax for an input tag: <input type="option" name="text" /> Types available: text checkbox button password radio hidden reset submit Other ways to input data: <textarea> <select> In HTML5, there are now even more ways to input data, although not all browsers support all of the new input type values. Week 7 Slide 11 of 25

<input type= text /> <input type="text" name="variablename" size="xx" maxlength="yy" value="default-value" /> Creates a single-line box for your user to place data. You can set the size, maximum length, and default values if you wish. Example: Enter your first name: <input type="text" name="firstname" size="40" maxlength="40" value="enter First Name" /> Week 7 Slide 12 of 25

<input type= password /> <input type="password" name="variablename" size="xx" maxlength="yy" value="default-value" /> Works the exact same way as the text type, but when a user types in the information, asterisks appear instead of text. However, this text is sent to the server in clear-text format! Example: Enter your password: <input type="password" name="pass" size="10" maxlength="10" /> Week 7 Slide 13 of 25

<textarea>default text<textarea> Allows user to submit more than one line of text. Usually used for comments or leaving feedback. <textarea rows="xx" cols="yy" name="variablename" wrap="off soft/virtual hard/physical">default text</textarea> Rows: number of rows Cols: number of columns Name: variable's name Wrap: Off=no wrapping of text allowed Soft or Virtual=wrapping is on, but text is sent to the CGI script as a single line of text, without line breaks Hard or Physical=wrapping is on, and when the text is sent to the CGI script, it is sent with line breaks Comments? <textarea rows="3" cols="40" name="comments" wrap="virtual"> Enter comments </textarea> Week 7 Slide 14 of 25

<input type= radio /> Provides a group of buttons from which only one may be chosen <input type="radio" name="variablename" value="value" /> If you want a radio button to be pre-selected, add the attribute "checked". Example: <br /><input type="radio" name="univ" value="stanford" />UCLA <br /><input type="radio" name="univ" value="stanford" />Harvard <br /><input type="radio" name="univ" value="stanford" />Oxford <br /><input type="radio" name="univ" value="stanford" checked="checked" />Stanford Week 7 Slide 15 of 25

<input type= checkbox /> Works just like the radio button, except that more than one value can be selected. <input type="checkbox" name="variablename" value="value" /> Example: <br /><input type="checkbox" name="computer" value="mac" />Macintosh <br /><input type="checkbox" name="computer" value="unix" checked="checked" />Unix <br /><input type="checkbox" name="computer" value="winxp" /> Windows XP <br /><input type="checkbox" name="computer" value="win8" /> Windows 8 Week 7 Slide 16 of 25

<select></select> The select element shows a list of choices in as a pull-down menu. <select name="class-enjoyment"> <option value="bored">i m bored with the class</option> <option value="great" selected="selected">this class is great!</option> </select> If instead of a pull-down menu, a list box is desired, add the SIZE attribute (size refers to the number of items): <select name="class-enjoyment" size="2"> <option value="bored">i m bored with the class</option> <option value="great">this class is great!</option> </select> Week 7 Slide 17 of 25

More <select> To allow a user to select more than one item, the MULTIPLE attribute is used: <select name="favorite-food" multiple="multiple"> <option value="hamburger">hamburgers</option> <option value="pizza">pizza </option> <option value="tacos">tacos </option> <option value="vegetables">vegetables </option> </select> Week 7 Slide 18 of 25

<input type= reset /> This choice allows the user to reset and clear all of the data fields to their default values. <input type="reset" value="text" /> Whatever is put in the text for the value attribute will be what is seen as the Reset button. <input type="reset" value="clear all choices and start over again" /> Week 7 Slide 19 of 25

<input type= submit /> The submit value displays a push button with the preset function of sending the data in the form to the server to be processed, as defined by the action attribute in the <form> tag. <input type="submit" value="text" /> Whatever is put in the text for the value attribute will be what is seen as the Submit button. <input type="submit" value="click here to submit your choices" /> Week 7 Slide 20 of 25

<input type= image /> Sometimes, designers wish to create their own submit button using a graphical program. The image value works exactly the same way the submit value works. The SRC attribute defines the URL of the image; the ALT attribute will be displayed if the browser is incapable of displaying images; the width and height attributes define the width and height of the image; the border attribute defines whether a border is desired. <input type="image" src="url-of-image" alt="text" width="xx" height="yy" border="0" /> <input type="image" src="http://www.company.com/images/ clickme.gif" alt="click Me to Submit" width="30" height="10" border="0" /> Week 7 Slide 21 of 25

<input type= button /> Sometimes you'll want to create a webpage that will do an action but won't submit the entire data. For example, you might create a Javascript program to calculate the shipping cost or the tax of a potential order. Whatever is placed in the value attribute will be displayed as the button; the name will be the name called by the script. <input type="button" value="text" name="name" /> This requires the use of a scripting language to tie an event to the button and create an action. <input type="button" value="calculate Interest" name="calculator" /> Week 7 Slide 22 of 25

Hidden Allows webmasters to submit default or previously specified text that is hidden from the user. <input type="hidden" name="name" value="text" /> Week 7 Slide 23 of 25

Hidden Week 7 Slide 24 of 25

input type="password" Form Example input type="text" input type="submit" input type="image" <textarea> input type="text" input type="password" <select> input type="radio" input type="submit"