Click to skip over navigation
 

lecture 9: input types II

<< previous slide

return to lesson 9 index

next slide >>


3. special inputs

There are two of these worth mentioning here. The first is that you can allow users to submit a file, like so:

<p>Please attach your CV file to the form</p>
<input type="file" size="15" />

Please attach your CV file to the form

The second is the "hidden" input. This doesn't appear on the screen at all, and the visitor cannot therefore change the name-value pair being sent. This may seem pointless, but there may be a need to receive some "control" information: perhaps you have more than one web site sending information to the same place and it is helpful to know which site is being used in each instance:

<input type="hidden" name="formorigin" value="HTML site" />

4. buttons

The concept of form buttons should be familiar to anyone who's browsed the web before. Every form that is actually meant to gather information (as opposed to being just decorative) needs a submit button, or it is useless. It is courteous to always include a reset button as well.

COnfusingly, value is used on buttons to define the text which appears on the button. (It would have been better to have used a different attribute, but that's not my decision I'm afraid!) If it is left off, the browser uses its default value - "Submit" or "Reset" accordingly. See the examples here where a value has been used on one button but not the other.

    

<input type="submit" value="Send your details" />
<input type="reset" />

The "roles" played by these two buttons are built into browsers so they work automatically. However, it is possible to include buttons which are not directly related to the working of a form, by using input type="button" - here the value attribute is compulsory. You can code JavaScript events into buttons like this. There are various examples of this technique elsewhere on the site.




<< previous slide

return to lesson 9 index

next slide >>