Click to skip over navigation

Web Design

   

name/value pairs



main menus


help pages


Valid XHTML 1.0!

 

Form output is dealt by way of name-value pairs. This means that each form entry has to have a name, and each name can take a number of values. An example will help to illustrate this. If you think of a simple form which asks for the address and username of students, you would set up the form so one entry was called address, and one entry was called username. Each person filling in the form would enter their username in the username field, and their address in the address field. When the form is submitted the program receiving the form data (an e-mail client or a CGI script - see the page on form processing for details) as values attached to that name. The input the program would receive, therefore, would be something like this:

Name

Value

Username

eco6abc

Address

1 Studenty Street, Leeds LS6

The names (and in some types of form input the values) are defined within the HTML code, usually in <input> tags. The best thing to do at this point is move on to the page about input types, because this will show you where and how the name and value attributes work together. Be very clear, however, about the fact that it is these attributes which define what the form returns, and only the attributes. Whatever text you place around the vicinity of the form is completely irrelevant.

On the form on the input types page, the form elements are named, in turn: yourname, password, mf, what and options. The values they are associated with will depend on the input, but note, when you look at that page, that the values of yourname and password depend entirely on what the user types - the others are defined using value attributes in the tags, and depend on what box the user selects from a list.

Back to the top

Back to the menu for lesson 9



Material on this site is © Drew Whitworth, 2005 Permission will usually be given to reproduce material from this site for non-commercial purposes, if credit is given. For enquiries, e-mail Drew at andrew [dot] whitworth [at] manchester [dot] ac [dot] uk.