This article focuses on the use of radio buttons for HTML input tags, as well as the practice of radio default buttons for HTML input tags. Now let's take a look at this article.
First we introduce the practice of radio buttons in the HTML input tag:
<input> tags are used to collect user information. The input field has many forms, depending on the value of the type attribute. The input field can be a text field, a check box, a masked text control, a radio button, a button, and so on.
Words do not say much, on the code example:
<form action= "form_action.asp" method= "get" ><input type= "Radio" name= "Radio" value= "1" > Radio 1<input Type = "Radio" name= "Radio" value= "2" > Radio 2<input type= "Radio" name= "Radio" value= "3" > Radio 3<input type= "Radio" name = "Radio" value= "4" > Radio 4</form>
This effect is easy to see, let's look at the display in the browser first:
This effect can be seen at a glance, a very simple code
There is also a lot of sites are often seen, such as: Radio sex, this is basically used in this kind of box to make. The code is as follows:
The radio button in HTML implements male and female selection, does not allow both sexes to be able to choose, the implementation method: Write a Name property in the button's properties, and set the value of name to the same
<input id= "man" type= "Radio" checked= "Checked" name= "1"/> male <input id= "woman" type= "Radio" name= "1"/> Female
This will not give a diagram, than the above that is simple, on the two radio box, we often encounter this.
Now let's say how the HTML Radio box button is selected by default:
First we take the first example and continue to say that we only need to add a property in it, as follows:
<form action= "form_action.asp" method= "get" ><input type= "Radio" name= "Radio" value= "1" > Radio 1<input Type = "Radio" name= "Radio" value= "2" checked> Radio 2<input type= "Radio" name= "Radio" value= "3" > Radio 3<input type= " Radio "Name=" Radio "value=" 4 "> Radio 4</form>
The effect is still obvious, see:
I do not have any click on the above, I appear on top of it, after the refresh can be seen on the Radio 2 above.
We can see, so that the radio box is selected by default, you can try it yourself, more knock code.
OK, the above is the article about the HTML input tag to do radio button, the problem can be asked below.