reading_notes

Read: 09 - Forms and Events:

Forms:

An HTML form is used to collect user input. The user input is most often sent to a server for processing.

Types of Form Controls:

Types of Forms

How Forms Work?

  1. A user fills in a form and then presses a button to submit the information to the server.
  2. The name of each form control is sent to the server along with the value the user enters or selects.
  3. The server processes the information using a programming language It may also store it in a database.
  4. The server creates a new page to send back to the browser based on the information received.

Form Structure:

<form action="http://www.example.com/subscribe.php" method="get"> <form> controls live inside a <form> element. <action> Its value is the URL for the page on the server that will receive the information in the form when it is submitted. <method> Forms can be sent using one of two methods: <get> or <post> <get>: the values from the form are added to the end of the URL ideal when: short forms or just retrieving data from the web server (not sending) <post>: values are sent in what are known as HTTP headers. ideal when the form: upload a file, very long, contains sensitive data, add or delete from database.

HTML5 Form Validation:


Lists, Tables & Forms:

Bullet Point Styles:

list-style-type:

Property allows you to control the shape or style of a bullet point (also known as a marker).

list-style-image:

You can specify an image to act as a bullet point using the list-style-image property.

list-style-position:

Indicates whether the marker should appear on the inside or the outside of the box containing the main points.

outside: list-style-position: outside; , inside: list-style-position: inside;

list-style:

Shorthand allows you to express the markers’ style, image and position properties in any order.

Table Properties:

Border on Empty Cells:

To specify whether or not their borders should be shown; If you have empty cells inyour table.

Gaps Between Cells:

Styling Forms:

Styling Text Inputs:

Styling Submit Buttons:

Styling Fieldsets & Legends:

Aligning Form Controls: Problem:

Labels for form elements are often different lengths, so the form controls will not appear in a straight line.

The solution: each topic we ask the user about is placed inside a <div> element to ensure that each question appears on a new line. Then we use styling by css and easily select forms by div and span.

Cursor Styles:

The cursor property allows you to control the type of mouse cursor that should be displayed to users. Types: auto, crosshair, default, pointer, move, text, wait, help, url(“ “)


Events:

HTML events are “things” that happen to HTML elements.

When JavaScript is used in HTML pages, JavaScript can “react” on these events.

examples of HTML events:

Common HTML Events

| Event | Description | |———|————| | onchange | An HTML element has been changed | | onclick | The user clicks an HTML element | | onmouseover | The user moves the mouse over an HTML element | | onmouseout | The user moves the mouse away from an HTML element | | onkeydown | The user pushes a keyboard key | | onload | The browser has finished loading the page |

TERMINOLOGY

Event Description
input Value in any <input> or <textarea> element has changed
change Value in select box, checkbox, or radio button changes
submit User submits a form (using a button or a key)
cut User cuts content from a form field
copy User copies content from a form field
Paste User pastes content into a form field
select User selects some text in a form field

How Events Trigger JavaScript Code:

event handling:

  1. Select the element node(s) you want the script to respond to.
  2. Indicate which event on the selected node(s) will trigger the response.
  3. State the code you want to run when the event occurs.

Event Handling

Three ways to bind an event to an element:

1- HTML Event Handlers 2- Traditional DOM Event Handlers 3- DOM Level 2 Event Listeners

Traditional DOM Event Handlers:

Traditional DOM Event Handlers

Event Listeners:

Event Listeners

Simple Summary from the book: