When using your computer you'll be quite accustomed to various user interface elements. For example, the Windows operating system has a number of standard elements such as buttons you can click, lists, drop down list boxes, and radio buttons you can select from, and checkboxes you can tick. The same applies with any Graphical User Interface (GUI) operating system, whether it's on the Apple Mac, Unix, or Linux. These elements are the way we now interface with applications. The good news is that we can include many of these types of element in our web page and, even better, it's very easy to do so. Once we have such an element, say a button, inside our page we can then tie code to its events. For example, when the button is clicked, we can fire off a JavaScript function we've created.
It's important to note at this point that the elements I'm talking about in this chapter are the common elements made available by HTML, and not ActiveX elements, Java Applets or plug-ins.
All of the HTML elements used for interaction must be placed inside an HTML form. Let's start by taking a look at HTML forms and how we interact with them in JavaScript.
HTML Forms
Forms provide us with a way of grouping HTML interaction elements with a common purpose together. For example, a form may contain elements that enable the input of a user's data for registering on a web site. Another form may contain elements that enable the user to ask for a car insurance quote. It's possible to have a number of separate forms in a single page. Pages containing multiple forms need not worry us until we are submitting information to a web server - then we need to be aware that only the information from one of the forms on a page can be submitted to the server at once.
To create a form, we use the <FORM> and </FORM> tags to declare where it starts and where it ends. The