Why are my 2 radio buttons not linked | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
10th May 2024, 10:42 PM
🇸🇾 Abdulaziz Alnaser 🇸🇩
🇸🇾 Abdulaziz Alnaser 🇸🇩 - avatar
8 Answers
+ 7
I noticed that you can select both yes and no. To prevent this you must add the name attribute to your inputs   <input type="radio" id="radio2" name="newspaper">
10th May 2024, 11:54 PM
Chris Coder
Chris Coder - avatar
+ 5
Hope this link helps you The <input type="radio"> defines a 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. https://www.w3schools.com/tags/att_input_type_radio.asp
10th May 2024, 11:01 PM
SoloProg
SoloProg - avatar
+ 4
Looks like it worked, since you added the name attributes to your code. So what are you saying?
12th May 2024, 6:25 AM
Chris Coder
Chris Coder - avatar
+ 3
SoloProg thx bro
11th May 2024, 9:25 AM
🇸🇾 Abdulaziz Alnaser 🇸🇩
🇸🇾 Abdulaziz Alnaser 🇸🇩 - avatar
+ 2
Chris Coder it didnt work
11th May 2024, 9:23 AM
🇸🇾 Abdulaziz Alnaser 🇸🇩
🇸🇾 Abdulaziz Alnaser 🇸🇩 - avatar
12th May 2024, 10:04 AM
🇸🇾 Abdulaziz Alnaser 🇸🇩
🇸🇾 Abdulaziz Alnaser 🇸🇩 - avatar
+ 1
It looks like you have it working now. Just a reminder to keep in your notes, for Radio Button Options: adding name makes it a choice between them rather than being able to select both and not deselect.
12th May 2024, 2:39 PM
Heather Ambrosio
Heather Ambrosio - avatar
0
Phython
12th May 2024, 8:27 AM
Vinesh 10
Vinesh 10 - avatar