Adding Buttons to a Form
Sometimes you need more then one button in your form. It's easy we will use the button tag. Let's see it in action.
Video Transcript
00:00Alright, so in our last video, we last left off where we're building a form together,
00:05if you recall.
00:06And in that form, we saw that we added a label, and we saw how we could connect that label
00:11to different elements, such as the input.
00:14And we saw that the input has a few different types.
00:16There's an email type, there's a submit type, and there's many other types that we're
00:20not going to explore all in these videos, but I encourage you to check them because
00:24they're relatively easy once you know how to work with it.
00:28The next thing I want to talk about is buttons.
00:30Now, although the submit and input type is a type of button, I want to show you how
00:34could you create the exact same button using the submit button.
00:40Now how do you do that?
00:41Well, basically what we would do is we would create a new button tag.
00:47And in many ways, the button tag is kind of redundant.
00:50It's basically the same idea of the input.
00:52It's only more shortly typed because it's just directly a button.
00:56As soon as we do that, we've already added a button into our page.
01:00Now we have an opening tag and a closing tag for our button.
01:04Now, what we could do for our button is we could set for it different properties.
01:10And we basically could configure and tell the button what type of button it is.
01:14So we could say that the type of it could be the default type, which is button.
01:18We could set the default type to be a button.
01:21And we could put whatever value we want inside of here.
01:24Contrary to, well, that's not right, that's it, read zero to geek.com.
01:29Contrary to the input, which we didn't put anything in its content,
01:33it didn't have content, the only thing we could put in was the actual value.
01:37And that value was the value of the input element.
01:40For the button, I could actually put inside of it content.
01:43And now this content could also be an image.
01:46This content doesn't have to be only text.
01:48So as you already know how to create images,
01:50you could put inside your own image and use an image inside of your button
01:53as a value.
01:55So if you go and see this in a browser for a second just to see what
01:57happened with this update, and I click on refresh,
02:00we'll see now we have also a zero to geek button added in.
02:04Now, that's the zero to geek button.
02:06It doesn't really do anything right now because it's not connected to any code
02:09that would make it do anything.
02:11Contrary to the submit button, which is connected to the form submission.
02:15Now, if we go back into our source code for a second,
02:17we'll see the main reason why it's not really doing anything
02:20is because it's not a submit button.
02:22But we could set it to be a submit button.
02:24So there's actually three types.
02:26There's a button type, a submit type, and a reset type.
02:30Now, if we set it to submit, it would basically
02:32act the same way as a submit button.
02:34So there's no point in showing that just by typing
02:36the word submit in our type.
02:38The next type is the reset.
02:40And by the way, all these possible options
02:42you could create with the input as well.
02:44And really, the only big difference between a button and an input type
02:47is that a button enables you also to add images into your button area.
02:51So it gives you much more freedom and control over the text
02:54that you would have inside of the button.
02:56OK.
02:57OK.
02:57If I set it to be as a reset, and I go back into my application
03:03and refresh, and this time around, I start typing something inside here.
03:07Once I click on my reset button, it's going to delete everything
03:10and reset the form.
03:11And no matter how many components are on the stage,
03:13it's going to clear them out and basically reset them,
03:15enabling you very, very easily and very quickly
03:18to create a reset button.
03:19Obviously, at this stage, it would probably
03:20make sense to write here reset, because that would probably
03:23be more accurate.
03:24Now, the button has other properties and things,
03:27but we're not going to dig into them,
03:28because they're not that important right now.
03:30At some point towards the end of our training,
03:32we'll look at a few different global properties of all input
03:37types.
03:37And a button is another input type.
03:40So it really is just a stripped out input type, right?
03:44Does that make sense?
03:45Yeah.
03:46Perfecto.
03:47So that's all I really have to say about buttons.
03:49They're very similar to inputs, and they work very similarly.
03:52You could work either or.
03:53Every browser supports both options.
03:57OK?
03:57Right.
