HTML: Forms, HTML Forms, HTML Forms

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Data input control

radio button, checkbox, a submit button, a reset button, or a selection (drop-down) menu.

Simple Form Controls: Typically unique throughout a form

radio buttons are an exception

Menu Controls: select element

represents control as a whole - must contain two or more options

Text area controls: rows attribute

sets height of text area in lines of text

Text area controls: cols attribute

sets width of text area in average character widths

method attribute

tells browser how to submit the form data set - get or post

action attribute

tells browser where to send the form data set - URL of form processor

Form controls

text input, submit button, radio buttons, checkboxes, menus, text areas, etc. Treated like large characters of text - must be structured with other HTML elements

What are forms

the basis of the interactive web

legend element

use as first child of fieldset - provides text browser can use to label fieldset

<input type="range">

used for input fields that should contain a value within a range. forms a bar that slides to give a specified value

type=

An attribute that defines the control for the <input>. Default is "text", other common choices are: "email", "radio", "checkbox", "submit", "button", "date", "time", "month", "week", "color", etc.

value=

An attribute that specifies the field.

for=

An attribute used together with the <label> element to specify which form element a label is bound to. Example: xxxxxxxxxxx="username"

Forms

Are used to gather information from the vistor

<form> form elements </form>

Basic structure of a HTML form

What is the difference between "get" and "post" methods?

GET - Requests data from a specified resource POST - Submits data to be processed to a specified resource

Textarea

Creates a multiple-line field for a relatively large amount of text.

Text

Creates a single- line field for a relatively small amount of text

"min" attribute

Specifies the minimum value for an input field

Form processors

programs that run on server to process a submitted form

<form target="_blank"> </form>

Specifies the target of the address in the action attribute (default: _self).

Which two attributes link <label> to <input> with a matching value?

"for" and "id"

Form data set

- Set of name-value pairs compiled by browser and sent to form processor - Only successful controls included

Text input controls (type="text")

Accept a single line of text input - text may exceed control size, scrolls to left as needed - Size attribute - avg length - Max attribute - max number of characters - Value attribute - default contents of control (usually avoided)

Password input controls (type="password")

Accept a single line of text input hidden without displaying the actual characters typed - Security extends only to people viewing screen no storage protection - size and max length attributes

placeholder=

Adds temporary text in a field to show the user what to type there.

What do forms do

Allow users to provide input to programs that get run on a server

Checkbox

Creates a list of item

Select

Creates a menu of choices from which a visitor selects.

Password

Identical to text fields used dfor single-line data entry.

empty element

It doesn't need a closing tag. Example: <input>

Reset

Resets the form

"required" attribute

Specifies that an input field is required (must be filled out)

<input type="submit" formtarget="_blank" value="Submit to a new window">

The formtarget attribute specifies a name or a keyword that indicates where to display the response that is received after submitting the form

<input type="image" src="img_submit.gif" alt="Submit" width="48" height="48">

The height and width attributes specify the height and width of an <input> element. The height and width attributes are only used with <input type="image">.

fieldset element

groups related elements within a form - use to structure forms

<button type="submit"> vs. <input type="submit">

<input> only allows plain text as its label whereas <button> allows full HTML content, allowing more complex, creative button text.

Text area controls

Allows user to enter multi-line text responses - scroll bars appear as necessary

method=

An attribute which defines how to send the data with (it can be "get" or "post").

action=

An attribute which defines the location (URL) where the form's collected data should be sent when it is submitted.

name=

An attribute which identifies the element. For example, the server uses this attribute to identify the fields in form submits.

id=

An attribute which uniquely identifies the element. In a form, it matches the <label>"for" attribute to tie the <label> to the <input>.

<textarea>

An element that creates a definable and user-sizable text area.

<input>

An element that defines the interactive controls for web-based forms in order to accept data from the user.

<label>

An element that represents a caption for an item in a user interface.

Input control

Any type of input mechanism of a form

<input name="name of form">

Defines a name from the input area

<input type="text">

Defines a one-line input field for text input:

<input type="submit">

Defines a submit button (for submitting the form) User types in a response

<input type="radio">

Defines radio button input (for selecting one of many choices)

<input type="radio" value="name of choice">

Gives a name to one of the multiple choices (radio input)

Submit buttons (type="submit")

Produces a button the user can click to submit the form

Radio buttons (type="radio")

Produces a single circular control that can be on or off - used in collections of two or more - Needs exclusive choices (when one group turned on others need to be off) - Checked attribute - radio button is turned on by default

Checkboxes (type="checkbox")

Produces a single square control that can be on or off - may be used singly or in collections - Possibly inclusive options - Checked attribute - tells browser to turn checkbox on by default

Hidden input controls (type="hidden")

Provides a fixed name-value pair that will always be submitted within form-data set - Allows HTML to determine value w/o users knowledge

"disabled" attribute

Specifies that an input field should be disabled

<form method="GET" > </form>

Specifies the HTTP method used when submitting the form (default: GET).

"step" attribute

Specifies the legal number intervals for an input field

"maxlength" attribute

Specifies the maximum number of character for an input field

"max" attribute

Specifies the maximum value for an input field

Submit

Submits forms for processing.

<output name="x" for="a b"></output>

The <output> element represents the result of a calculation (like one performed by a script).

<input type="text" name="fname" placeholder="First name">

The placeholder attribute specifies a hint that describes the expected value of an input field (a sample value or a short description of the format). The hint is displayed in the input field before the user enters a value.

<form action="action_page.php"> Username: <input type="text" name="user"> Encryption: <keygen name="security"> <input type="submit"> </form>

The purpose of the <keygen> element is to provide a secure way to authenticate users. The <keygen> element specifies a key-pair generator field in a form. When the form is submitted, two keys are generated, one private and one public. The private key is stored locally, and the public key is sent to the server. The public key could be used to generate a client certificate to authenticate the user in the future.

<input type="text" name="firstname" value="John">

The value attribute specifies the initial value for an input field

<input type="button" onclick="alert('Hello World!')" value="Click Me!">

defines a button

<input type="checkbox">

defines a checkbox Checkboxes let a user select ZERO or MORE options of a limited number of choices.

<input type="password">

defines a password field The characters in a password field are masked (shown as asterisks or circles)

Simple Form Controls: type attribute

determines which type of control is produced

Simple Form Controls: input element

empty, replaced element that produces a wide variety of control types

Simple Form Controls: name attribute

establishes name that will be used for control's value in form data set

Simple Form Controls: id attribute

establishes unique identity of each control

Text area controls: textarea element

produces large box for textual input - container, replaced element

Text area controls: name attribute

provides name for name-value pair in form data set

form element

represents form as a whole

label element

used to label form controls

for attribute

value matches id attribute of associated control


Set pelajaran terkait

Analysis of Behavior CH.5 -- Quiz 1,2,3

View Set

Database Maximun(meo mu vo ca ran) > - <

View Set

Chapter 25 Pharm Muscle Relaxants

View Set

Therapeutic Interventions Related to the Male Reproductive System

View Set

Personal Finance Final Exam Review

View Set

ATI Fundamentals Practice Questions

View Set

Kaplan Behavioral Science Comprehensive

View Set