WEBVTT

0
00:00.590 --> 00:02.750
Welcome back to another cool lecture.

1
00:02.750 --> 00:07.880
And to remind you, we're talking about the input where its type is set to hidden.

2
00:07.880 --> 00:14.120
And in the previous lectures we've seen that there are 3 main uses for this input type, right?

3
00:14.150 --> 00:22.610
The main use is to use it to help you when it comes to database lookups. Specifically, a popular use

4
00:22.610 --> 00:29.780
of using input type hidden is to keep track of what database record needs to be updated.

5
00:29.930 --> 00:31.100
Okay, Clyde, I get it.

6
00:31.100 --> 00:32.300
But how does this work?

7
00:32.300 --> 00:34.490
What is the typical workflow look like?

8
00:34.910 --> 00:38.240
Well, I've broken it down into three very broad categories.

9
00:38.240 --> 00:44.720
Step number one is the starting point, and here the user generally decides to edit some content they

10
00:44.720 --> 00:50.510
have control over, such as a blog post or a product entry or their profile.

11
00:50.510 --> 00:55.280
And of course the user starts this whole process by clicking on an edit button of some sort.

12
00:55.730 --> 00:56.660
So that's the first step.

13
00:56.660 --> 00:57.740
Very intuitive.

14
00:57.770 --> 01:05.220
Step number two, is where the database comes into the picture, because the content to be edited has

15
01:05.220 --> 01:06.840
to be taken from somewhere, right?

16
01:06.870 --> 01:14.280
It has to be fetched from the database and loaded into an HTML form to allow the user to make changes.

17
01:14.280 --> 01:18.330
And the final step is pretty intuitive as well.

18
01:18.360 --> 01:25.560
After editing, the data is updated. And when the user submits the form, the updated data is sent back

19
01:25.560 --> 01:28.920
to the server to be updated in the database.

20
01:28.920 --> 01:30.960
So the idea here is pretty simple.

21
01:30.960 --> 01:40.770
During step two, the ID of the record being updated is kept in a hidden input, right, in its value attribute.

22
01:40.770 --> 01:42.690
So it may look like this, for example.

23
01:42.990 --> 01:43.890
Make sense.

24
01:43.890 --> 01:45.750
And then we get on to step three.

25
01:45.750 --> 01:53.820
When the form is submitted, the ID is automatically sent back to the server with of course, the form

26
01:53.820 --> 01:55.320
and record content.

27
01:55.320 --> 02:02.730
And the ID is so important my students, because it lets the site's server side component know exactly

28
02:02.730 --> 02:08.040
which record in the database needs to be updated, with the submitted data.

29
02:08.040 --> 02:14.160
So I thought I'd spend just this lecture explaining why it's useful from a database perspective, and

30
02:14.160 --> 02:16.170
I hope it's starting to make sense.

31
02:16.170 --> 02:22.170
I hope you can kind of get an intuitive feel for how you would use this input type.

32
02:22.200 --> 02:23.850
See you in the next lecture.