Ask coding questions

← Back to all posts
Radio buttons not working in HTML
RixTheTyrunt

Please help, I want to fix one of bugs, and here's what you can/can't do with it:

Halp me

Answered by NFadhlurrahman [earned 5 cycles]
View Answer
Voters
RixTheTyrunt
Comments
hotnewtop
NFadhlurrahman

You can select all options

To fix this bug, all of the radio buttons must have the same value of the name attribute.

Example:

RixTheTyrunt

( <<:D) ( Kaomojis look like Tyrunts right now ) It works!

AmoghTheCool

@RixTheTyrunt I see what you mean, a better way to do this is to use the select tag with option children:

I think that to get the data, you have to use select_item.selectedIndex and that returns an index of the options that shows which one is selected, so select_item.options[select_item.selectedIndex].innerText is the option which is selected. options can be selected and unselected and only one can be selected.

As far as I know, radio buttons are always multiselect and anyway
a dropdown is more appropriate for the situation.

RixTheTyrunt

I see what you mean, a better way to do this is to use the select tag with option children:

Check the answer! I hope that will improve your coding... ( <<:P)