Chapter 7. HTML Forms: Interacting with the User

Web pages would be very boring if you could not interact with or obtain information from the user, such as text, numbers, or dates. Luckily, with JavaScript this is possible. You can use this information within the web page, or it can be posted to the web server where you can manipulate it and store it in a database if you wish. This chapter concentrates on using the information within the web browser, which is called client-side processing.

You're 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 boxes you can check. The same applies with any graphical user interface (GUI) operating system, whether it's a Mac, Unix, or Linux system. These elements are the means by which you now interface with applications. The good news is that you can include many of these types of elements in your web page — and even better, it's very easy to do so. When you have such an element — say, a button — inside your page, you can then tie code to its events. For example, when the button is clicked, you can fire off a JavaScript function you created.

It's important to note at this point that the elements discussed in this chapter are the common elements made available by HTML, and not ActiveX elements, Java Applets, or plug-ins. You'll look at some of these in Chapter ...

Get Beginning JavaScript®, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.