From the course: JavaScript for Web Designers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Radio buttons and checkboxes - JavaScript Tutorial
From the course: JavaScript for Web Designers
Radio buttons and checkboxes
- [Instructor] In this video, we're going to look at another pair of form input types: check boxes and radio buttons. They're a little more complicated to deal with than text fields or select boxes because they can be on or off, but also carry a value the way other inputs do. Let's scroll down a little bit so we can see our radio buttons and check boxes of interest. We'll start with the check boxes. I'll check this one and inspect it. So I have a label field here, and then a little check box that goes with it, appears before. So I'm going to copy its ID and we'll switch back over to the JavaScript console and select it using document.getElementById. All right, let's look at its value first, the same way we did with the text fields. We come back with Yes. Okay, let's turn it off and try that again. Same thing. Okay, so this is obviously not working the way we might expect, at first. But the value attribute on this…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Working with user info4m 44s
-
Text fields and select boxes5m 45s
-
(Locked)
Radio buttons and checkboxes5m 30s
-
(Locked)
Changing submission with events4m 21s
-
(Locked)
Starting to validate input4m 15s
-
(Locked)
Disabling and enabling fields5m 14s
-
(Locked)
The basics of sanitizing user input7m 1s
-
(Locked)
Get and set with innerHTML6m 58s
-
(Locked)
Challenge: Add and use more fields56s
-
(Locked)
Solution: Add and use more fields3m 23s
-
(Locked)
-
-
-
-