Current section: Inputs 59 exercises
Problem

Hidden Inputs

Loading exercise

Transcript

00:00 Sometimes, you have some data that you want to submit to the server with the request, but you don't want the user to have to enter that in. And so that is the use case for hidden inputs. So we've got our little ninja here, right? The hidden input, it's the input that the user cannot see, but will be submitted along

00:18 with the rest of the data that they're submitting. So this can be really useful if you've got like a checkbox that checks a task to be done, and maybe that checkbox can be the submit button. So you click on that, and that checks it, and it actually also submits the form.

00:33 You want to have a hidden input in there that will be the ID of the to-do that is getting checked off or unchecked, as the case may be. So that is the idea behind hidden inputs. We're going to add a hidden input to our form. So you will not be able to actually observe the difference in the UI, but you can take

00:52 a look at the DOM. And also when you submit that, you should see the value of that hidden input in there as well. We definitely use hidden inputs occasionally, so a useful thing for you to understand. Let's get to it.