You are here:   HomeHTML LanguageHTML TutorialHTML MARQUEE
by Dinesh Thakur Category: HTML

Radio buttons are mutually exclusive i.e. they allow the user to choose one of the several options. Selecting one turns the other options off. These buttons are viewed in the browser as small circles with a prompt and the selected one appears with a solid dot in it.

 

Syntax

 

<INPUT type = "radio" name = "radio-id" Value = "choice-id" checked>

 



Name: Applies to the collection of buttons, not just to a particular item. Browsers use the name attribute to decide which buttons belong to the same group and therefore which ones are to set and unset as a group.

Value: It is the value assigned by the user. These are predefined and they do not accept other input. Each radio button must be assigned a value.

Checked: It causes the radio button to be on when the form is first created. It is the default selection.

The code for Radio buttons is as shown below:

 

<HTML>

<HEAD><TITLE> TEXT FIELDS</TITLE></HEAD>

<BODY BGCOLOR="PINK">

<P ALIGN ="CENTER"><B>ADMISSION FORM</B>

<FORM>

<P>

<INPUT TYPE ="TEXT" NAME="NAME" VALUE="ENTER YOUR NAME:" SIZE="25" MAXLENGTH="30"> NAME<BR><BR>

<INPUT TYPE ="PASSWORD" NAME="PASSWD" SIZE="25" MAXLENGTH="30"><BR><BR>

<INPUT TYPE ="TEXT" NAME="ADDRESS" SIZE="25" MAXLENGTH="30">

ADDRESS<BR><BR>

<INPUT TYPE=”RADIO” NAME=”SEX” VALUE=”MALE” CHECKED>MALE<BR>

<INPUT TYPE=”RADIO” NAME=”SEX” VALUE=”FEMALE” >FEMALE<BR>

</FORM>

</BODY>

</HTML>

 

In the above example two radio buttons are added in our form and one is checked by default. Notice that related radio buttons share the same "name" but different values. The data sent by the group of radio buttons when the form is submitted is the value attribute of the selected radio buttons. These values are not seen by the user and are used at the time of form processing.



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.



What's New and Popular





Search Content







Advance Courses



Basic Courses



Advertise with Us