Beginning AngularJS

(WallPaper) #1

CHApTer 6 ■ WorkIng WITH ForMS


radio

The radio button control is perhaps the trickiest input type. Named after the old-fashioned radio sets, which
used buttons instead of a dial (or a scan function such as we have on modern radios), tuning among stations was
accomplished by using a series of buttons that were pre-tuned to certain stations. Pressing down on one button
caused any other depressed button to pop back up. It is the same with radio buttons on the Web; that is, you can
“depress,” or choose, only one button at any given time.
For this system to work, though, each radio button in the group from which you want your users to choose must
have the same name. In Listing 6-1, you can see that each radio button has been given a name of "station".


Listing 6-1. A Group of radio Buttons














A very important thing to note is that, while the name attribute has the same value in each case, the value
attribute differs. As the user does not actually enter any text into a radio button (that’s clearly impossible), there must
be a way to assign a meaning to each.
Unlike the name attribute, the id attribute should be unique. Here, the label element, through its for attribute,
relates itself to the input it is labeling. We will look at the label element again at the end of this section.


The textarea Element

The textarea element is similar to the text input, but it allows the user to enter multiple lines of text, as opposed to a
single line of text. This makes it ideal for larger amounts of text. Unlike the input element, a textarea element has an
opening tag in which only text content is allowed.



It’s easy to change the size of a textarea element by making use of the cols and rows attributes, which, as you
might imagine, specify the number of horizontal input lines (rows) and the width of the textarea in terms of columns.


Free download pdf