Traditionally, the term 'form' has referred to a printed document that contains spaces for you to fill in information.
HTML borrows the concept of a form to refer to different elements that allow you to collect information from visitors to your site.
The best known form on the web is probably the search box that sits right in the middle of Google's homepage.
There are several types of form controls that you can use to collect information from visitors to your site.
- Text input (single-line).
- Password input.
- Text area (multi-line).
- Radio buttons.
- Checkboxes.
- Drop-down boxes.
- Submit buttons.
- Image buttons.
- File upload.
2.The name of each form control is sent to the server along with the value the user enters or selects.
3.The name of each form control is sent to the server along with the value the user enters or selects.
(form): Form controls live inside a (form) element. This element should always carry the action attribute and will usually have a method and id attribute too.
(input): The (input) element is used to create several different form controls. The value of the type attribute determines what kind of input they will be creating.
name: When users enter information into a form, the server needs to know which form control each piece of data was entered into.
maxlength: You can use the maxlength attribute to limit the number of characters a user may enter into the text field.
size: The size attribute should not be used on new forms. It was used in older forms to indicate the width of the text input (measured by the number of characters that would be seen).
type="password": When the type attribute has a value of password it creates a text box that acts just like a single-line text input, except the characters are blocked out.
name: The name attribute indicates the name of the password input, which is sent to the server with the password the user enters.
size, maxlength: It can also carry the size and maxlength attributes like the the single-line text input.
(textarea): The (textarea) element is used to create a mutli-line text input. Unlike other input elements this is not an empty element. It should therefore have an opening and a closing tag.
checked: The checked attribute can be used to indicate which value (if any) should be selected when the page loads. The value of this attribute is checked.
type="checkbox": Checkboxes allow users to select (and unselect) one or more options in answer to a question.
checked: The checked attribute indicates that this box should be checked when the page loads. If used, its value should be checked.
for more information read this book Chapter 7: “Forms” (p.144-175) HTML CSS.
There are several CSS properties that were created to work with specific types of HTML elements, such as lists, tables, and forms.
for more information read this book Chapter 14: “Lists, Tables & Forms” (pp.330-357) HTML CSS.
- Bullet Point Styles (list-style-type).
- Images for Bullets (list-style-image).
- Positioning the Marker (list-style-position).
- List Shorthand (list-style).
- Table Properties
- Border on Empty Cells (empty-cells).
- Gaps Between Cells (border-spacing, border-collapse).
- Styling Text Inputs.
- Styling Su bmit Buttons.
- Styling Fieldsets and Legends.
- Alignin Form Controls: Problem and Solution.
- Cursor Styles (cursor).
When you browse the web, your browser registers different types of events. It's the browser's way of saying, "Hey, this just happened." Your script can then respond to these events.
Here is a selection of the events that occur in the browser while you are browsing the web. Any of these events can be used to trigger a function in your JavaScript code:
UI Events: Occur when a user interacts with the browser's user interface (UI) rather than the web page
- load: Web page has finished loading
- unload: Web page is unloading (usually because a new page was requested)
- error: Browser encounters a JavaScript error or an asset doesn't exist
- resize: Browser window has been resized
- scroll: User has scrolled up or down the page
- keydown: User first presses a key (repeats while key is depressed)
- keyup :User releases a key
- keypress: Character is being inserted (repeats while key is depressed)
- click: User presses and releases a button over the same element
- dbl click: User presses and releases a button twice over the same element
- moused: own User presses a mouse button while over an element
- mouseup: User releases a mouse button while over an element
- mousemove: User moves the mouse (not on a touchscreen)
- mouseover: User moves the mouse over an element (not on a touchscreen)
- mouseout: User moves the mouse off an element (not on a touchscreen)
When the user interacts with the HTML on a web page, there are three steps involved in getting it to trigger some JavaScript code. Together these steps are known as event handling.
- Select t he element node(s) you want the script to respond to.
- Indicate which event on the selected node(s) will trigger the response.
- State the code you want to run when the event occurs.
Event handlers let you indicate which event you are waiting for on any particular element. There are three types of event handlers.
- HTML EVENT HANDLERS
- TRADITIONAL DOM EVENT HANDLERS
- DOM LEVEL 2 EVENT LISTENERS
Event listeners are a more recent approach to handling events. They can deal with more than one function at a time but they are not supported in older browsers.
Here is the syntax to bind an event to an element using an event listener, and to indicate which function should execute when that event fires:
element .addEventlistener('event', functionName [, Boolean]) ;