Form Radio Button
Hi there, we're gonna make a radio button. It's this like weird little dot thing that you can connect one but you can't click both of them the same time. Okay. It's an aw one or the other. It's an input of radio. There it is there there's a few little quirks to make it work. So let's jump in now and learn how to do it in. Vieques code. Alright, let's put our radio button like the rest of them are going to put it inside just our wrapper. So it's on its own line. Okay. And inside of this we will do our input of radio. It's a nice simple one. Radio radio radio really has some quicks to it though. Okay, so the name this one is going to be let's say contact you start at the beginning there contact preference. Okay. And so this is a generic for both options. The idea is specific for this particular little button. So let's call this one phone. Okay, so let's save it and have a little look. We're missing bits but let's have a look. Okay, so I've got a radio button, I click it. Okay and the pro...
blem with it is that if you only have one radio button it can't be unclipped. Okay? It is is what's called an awe button. Okay, so a checkbox is an end. Okay, so if you have more than one checkbox, let's quickly do that. Here's my check box. I have two of these came Pace, pace, pace. Okay check boxes are cool. You can have I want this and that and then a bit of that. You can have them all that all ends A and D. Okay. Whereas a radio button K needs to be or I am this or something else, you need at least another one button in there. So I got this one, copy it, paste it. And the big thing you need these need to be the same. Okay. The name needs to be the same, but the idea needs to be different to make them unique. Okay. They also need values. Okay? So that when you get in your email it's gonna say let's put in value. Ok? It's going to say email. So I'm gonna get an email saying contact preference equals email. Okay? Or depending on the user picks contact preference equals phone that comes from this value here. So they both need it. Okay, so this one needs a value of what are we doing phone for this one? All right, so we're almost there now. The big thing is these need to be the same name and name because they toggle okay there or This one or this one. Okay. You can't have them on. Okay. That's what's called radio buttons. Like you might not be too old to remember these star ones. Okay, radios used to even like maybe a little bit before my time I was born in 1980. So these were in some cars, but on the way out, but basically you picked station. Okay. And if you picked another one, if you push that one in this button popped out was very mechanical. Okay so that's why that kind of radio button language kind of continues on pop. This one in this one has to pop out. Either this or that. You can have loads more of these as long as they use the same name and you need to give them different ideas. Otherwise you won't know what house did contact smoke signal putting in hyphens here. I should use lower case as well. But that's a stupid one Dan. Come on. Alright. So one thing we're going to do to tidy it up is it needs labels because it's like mystery buttons. Okay, so labels were gonna put them just afterwards. Like we did our checkbooks. Okay, so we're gonna put in label label four. Okay. It needs to be the same as the I. D. This is the label for the phone. And what is it going to say? It's going to see your phone. Okay. I should use lower case. Just you don't have to but later on, if I'm trying to control this with some other code, you've got to be consistent with things because otherwise you'd be like, hey, why isn't it working? It's because you've randomly used upper case when you haven't the rest of the course because people don't see what's in this stuff. Okay? They see in between the label here. So you can use uppers and lowers. Alright so the label again for the button that's just above it. It's gonna be four email matches up. This one's going to be email. Alright. Phone or email. Um Now, in terms of like a grander label, there's no like master label. So what we're going to have to do is just above it. Put in a P tag that says, how would you like to be contacted? Okay, It's just a P tag sitting above it to help explain this. Alright, my buttons all jammed in there. It doesn't go anywhere at the moment. All right. And that is radio buttons are a little sore. You or you? Big thing to remember the big takeaway to sear into your mind is that these need to be the same. Let's actually check with if you don't call themselves. So you called it something else. Okay. To what ends up happening is you've got two things that can be turned on and can't be turned off ever. Okay because they there's no toggle. One more thing before we go. I actually finished the video. I have to double back around because about half an hour later I realized this happened a little squiggly green line and that's coming from a plug in that we've got running called html hint. Okay. And basically if I click on it and kind of hover about it. Okay. It's God, the email must be unique. Okay. The I. D. S need to be unique. Okay, so this I. D. Email is unique for this like little group we made. Okay. Because the other one's called phone. Remember earlier on where we we used the I. D. Email already? Okay. So it needs to be unique. You can kind of see this little warning down here. Okay. It's telling me it must be unique. Telling me it's online 95 its character 60 so 95. Okay. In the little squiggly line. So this could be called email to. Okay. As long as it's unique and your label needs to match it as well. The value did not have to match up. All right. Save it. Now. We're finished with radio buttons. Let's get on to the next one.