Skip to the content.

Code 201 Class 9 Reading Notes

Forms

Definition, Traditionally, the term ‘form’ has referred to a printed document that conains spaces for you to fill in information.

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 such as PHP, C#, VB.net, or Java. It may also store the information in a database.

4) The server creates a new page to send back to the browser based on the information received.

A form may have several form controls, each gathering different information. The server needs to know which piece of inputted data corresponds with which form element.

<select>

A drop down list box (also known as a select box) allows users to select one option from a drop down list.

The <select> element is sued to create a drop down list box. It contains two or more <option> elements.

name

The name attrubite indicates the name of the form control being sent to the server, along with the value the user selected.

<option>

The <option> element is used to specifiy the optoins that the user can select from. The words between the opening <option> and closing </option> tags will be shown to the user in the drop down box.

value

The <option> element uses the value attribute to indiccate the value that is sent to the server along with the name of the control if this option is selected.

selected

The selected attribute can be used to indicate the option that should be selected when the page loads. The value of this attribute should be selected.

<form action ="http://www.example.com/profile.php">
  <p>What device do you listen to music on?</p>
  <select name="devices">
    <option value ="ipod">iPod</option>
    <option value="Radio">Radio</option>
    <option value="Cocmputer">Computer</option>
</form>

<—BACK