Need help with fixing radiobuttion selection. In the image, you can see all buttons selected but only one button should be selected and others should be deselected automatically. with Standard HTML Input type radio, it works fine. But I want to try with Lightning Input radio button
1 Answer
You need to specify a name
and value
, just as you would in normal HTML.
<lightning-input name={item.id} type="radio" value={item.options.a}></lightning-input>
This will allow you to get the radio behavior, as well as tell which item is selected.
Note that the name
must be the same for all type="radio"
that should behave as a single radio selection, which is why I used item.id as the unique name. You can derive another name if you desire, just make sure they are unique on the page.
Demo.
-
OMG @sfdcfox It worked!!!! Thanks so much. you are a pure genius. God bless you. Commented Mar 22, 2022 at 14:42