Chapter 12

Integrating Input and Output

IN THIS CHAPTER

Bullet Working with forms

Bullet Using input

Bullet Sending output

“Malfunction. Need Input.”

— NUMBER 5, SHORT CIRCUIT (1986)

Handling user input and sending back results are basic and necessary functions for any computer program. In this chapter, you find out how JavaScript and HTML can work together to receive and output data.

Understanding HTML Forms

The primary way to get input from users of web applications is through HTML forms. HTML forms give web developers the ability to create text fields, drop-down selectors, radio buttons, checkboxes, and buttons. With CSS, you can adjust the look of a form to fit your particular website. JavaScript gives you the ability to enhance the functionality of your form.

The form element

All HTML forms are contained within a form element. The form element is the container that holds the input fields, buttons, checkboxes, and labels that make up a user input area. The form element acts much like any container element, such as a div, article, or section. But it also contains some attributes that tell the browser what to do with the user input from the form fields it contains.

Listing 12-1 shows an HTML form ...

Get Coding All-in-One For Dummies, 2nd 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.