Radio Input Error [HTML] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Radio Input Error [HTML]

I created a radio with male and female values in HTML but the two radios check instead of one... Why? What is the solution?

4th Sep 2018, 4:55 PM
fps
fps - avatar
3 Answers
+ 6
Anthony Umeh <p>Choose sex</p> <p>Man: <input type="radio" name="sex" /> <br /> Woman: <input type="radio" name="sex" /> </p> check this code
4th Sep 2018, 5:09 PM
Niket
Niket - avatar
+ 3
To answer the why part... Giving both radio inputs the same value for the "name" property (as Niket demonstrated) tells the browser to treat them as part of the same group.
4th Sep 2018, 5:20 PM
Janningā­
Janningā­ - avatar
+ 1
Thanks
5th Sep 2018, 10:12 AM
fps
fps - avatar