Let us look at an example in which we display the information from a radio button group, in a text box. This may look complicated - but don't be put off. I have extended the basic principles of reading and writing the DOM into a more useful program. The parameter passed, r, stores the index for the radio button that was clicked. The HTML is fairly straightforward, although the use of event handlers may be new to you.
Event handlers make an element respond to an action.
We have met this is many guises already, a hyperlink is activated by clicking it, and programmers say that we handle the onclick event. A hyperlink may change its color when we move the mouse over it, and this is detected by an onmouseover event. There are many events, about 50 pre-defined ones, and in this program we detect two events, onload and onclick. When a radio button is clicked, the computer automatically selects it. We can also attach extra event handlers to the click event, and indeed have done.