0

Why radio input is not working?

It's supposed that you can only choose one answer when using this <input type ="radio"> why mine isn't working? https://sololearn.com/compiler-playground/WT3uHa59uhUu/?ref=app

4th Dec 2023, 8:31 PM
Elina
Elina - avatar
4 Answers
+ 8
Hi Elina, You need to add the name attribute to each radio button in the group. If you add name="1" after the id value for each radio button it will group them together and only 1 can be selected. It will look like this: <input type="radio" id="d" name ="1"> <label for="d">Male</label><br> <input type="radio" id="f" name="1"> <label for="f">Female</label>
4th Dec 2023, 8:36 PM
StuartH
StuartH - avatar
+ 2
StuartH thanks 😊 now I fixed it
4th Dec 2023, 8:45 PM
Elina
Elina - avatar
+ 1
Hey give same name in both radio so that only one is selected at a time
6th Dec 2023, 10:35 AM
Hritik Sharma
Hritik Sharma - avatar
+ 1
Hritik Sharma Thanks 😊
6th Dec 2023, 10:49 AM
Elina
Elina - avatar