HTML and CSS Reference
In-Depth Information
Figure 14-4: Special mobile device keyboard for URL form (left) and standard mobile keyboard (right).
297
RADIO BUTTONS AND CHECK BOXES: EASY-TO-SELECT INPUT ELEMENTS
If you're using radio buttons and check boxes with external programs accessing databases or
doing some other kind of server-side operation, it's very easy on the HTML5 side. Just use a
Submit button and everything gets sent to the server side for those programs to handle. (I
show you how to do that using a version of this example in Chapter 16.)
Because this next Web script bounces the input back to a
<textarea>
object on the page,
the entered data had to be checked using JavaScript with a little loop to i rst see whether the
checked
attribute was
true
or
false
. If the item has been checked, it then adds the value
to a
FormMaster
property named
this.countVal
. (It's like a variable, but in keeping with
DOM-like programming, it's assigned to an object.) Once that's i nished, it sends only those
checked to the output. h e following (rather long) Web script (
RadioCheck.html
in this
chapter's folder at
www.wiley.com/go/smashinghtml5
) does that.
<!
DOCTYPE HTML
>
<
html
>
<
head
>
<
script
type
=
”text/javascript”
>
FormMaster=new Object();
FormMaster.resolveForm=function()
{
this.countVal=””;