Wisdom
Wisdom

Reputation: 1

How to select a single radio option?

I can't select a single radio option. It's keeps selecting all radios

I created 4 radio option and I'm trying to select only 1 button, and it's keeps selecting all. I used pure html coding no JavaScript attached to it

Upvotes: 0

Views: 70

Answers (2)

Apip Munandar
Apip Munandar

Reputation: 29

Basically, the radio button on the html can only be selected only one, try to see documentation of html or w3school

Upvotes: 2

You're not naming them, name="Somename" is necessary to select only one option, input have to be named with same name.

Reference here.

<div>
  <h1>Named inputs</h1>
  <label><input type="radio" name="Somename"> Option1</label>
  <label><input type="radio" name="Somename"> Option2</label>
  <label><input type="radio" name="Somename"> Option3</label>
  <label><input type="radio" name="Somename"> Option4</label>


  <h1>Not named inputs</h1>
  <label><input type="radio"> Option1</label>
  <label><input type="radio"> Option2</label>
  <label><input type="radio"> Option3</label>
  <label><input type="radio"> Option4</label>
</div>

Upvotes: 1

Related Questions