Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

both of the radio buttons can be selected

Tags:

html

I have form with 2 radio buttons but both of the radio buttons can be selected,

     <form class="descriptions" id="collection"  method="post" action="">
                          <table width="200">
                              <tr>
                                <td>
                                  <label>Collection</label>
                                  <input type="radio" value="collection" />
                                </td>
                                <td>
                                  <label>Delivery</label>
                                  <input type="radio" value="delivery"    />
                                </td>  
                            </tr>
                         </table>

                </form>

I know this is very easy but I can't seem to find the answer, any help would be appreciated.

like image 688
akano1 Avatar asked Aug 12 '09 09:08

akano1


People also ask

Which radio button is selected?

To check which radio button is selected in a form, we first get the desired input group with the type of input as an option and then the value of this selection can then be accessed by the val() method. This returns the name of the option that is currently selected.

Why are both radio buttons selected HTML?

In HTML, a radio button is used to select one of many given choices. Radio buttons are shown in radio groups to show a set of related options, only one of which can be selected. A radio button in HTML can be defined using the <input> tag.

Can multiple radio buttons be selected?

Only one radio button in a given group can be selected at the same time. Radio buttons are typically rendered as small circles, which are filled or highlighted when selected.

Can you only select one radio button?

Radio buttons are normally presented in radio groups (a collection of radio buttons describing a set of related options). Only one radio button in a group can be selected at the same time.


2 Answers

Give them the same name.

like image 99
Noon Silk Avatar answered Oct 05 '22 06:10

Noon Silk


Description of the radio button control type in the HTML 4.01 specification:

Radio buttons are like checkboxes except that when several share the same control name, they are mutually exclusive: when one is switched "on", all others with the same name are switched "off".

like image 23
Gumbo Avatar answered Oct 05 '22 06:10

Gumbo