hamed
hamed

Reputation: 13

how select two radio button with one click?

<label for="foo">choose?</label>
<br>
<input id="id_1" type="radio" value="1" name="349">Google
<input id="id_2" type="radio" value="2" name="349">chrome
<br>
<input id="id_3" type="radio" value="3" name="349">Microsoft
<br>
<input id="id_4" type="radio" value="4" name="349">IE
<br>

When the key is pressed Google, Chrome button is selected at the same time. Thank you!

Upvotes: 0

Views: 2411

Answers (3)

Leo the lion
Leo the lion

Reputation: 3065

If you want easy answer then go with jquery solution and don't forget to change the name of radio button or else it will be difficult with same name... See here Demo I have added jquery onclick event and on click of google, selecting the another radio button. See fiddle for more info..hope it will help

Upvotes: 3

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167162

Radio button is supposed to be allowing only a single selection. You have got a few solutions here:

  1. Have a sub radio button.
    • Radio button with a different name.
  2. Have checkboxes instead of radio buttons.
    • Checkboxes are really used for multiple selections.

Snippet

This would demonstrate all the solutions:

<h2>Radios</h2>

<ul>
  <li>
    <input type="radio" name="comp" name="comp"> Company: Google
    <ul>
      <li><input type="radio" name="comp-g" id=""> Chrome</li>
      <li><input type="radio" name="comp-g" id=""> Chrome</li>
    </ul>
  </li>
  <li><input type="radio" name="comp" name="comp"> Company: Microsoft</li>
  <li><input type="radio" name="comp" name="comp"> Company: Apple</li>
</ul>

<h2>Checkboxes</h2>

<ul>
  <li>
    <input type="checkbox" name="comp" name="comp"> Company: Google
    <ul>
      <li><input type="checkbox" name="comp-g" id=""> Chrome</li>
      <li><input type="checkbox" name="comp-g" id=""> Chrome</li>
    </ul>
  </li>
  <li><input type="checkbox" name="comp" name="comp"> Company: Microsoft</li>
  <li><input type="checkbox" name="comp" name="comp"> Company: Apple</li>
</ul>

Upvotes: 0

Naveed Ramzan
Naveed Ramzan

Reputation: 3593

There are two solutions :

you need to change only two radio buttons - Google Chrome - Microsoft IE

and in this case you can make 2 radio buttons.

second solution, you can use jquery with same html.

if id_1 clicked then also id_2 should be checked and so on with 2nd Microsoft IE.

Upvotes: 0

Related Questions