I have a group of radio buttons (matrix) and it has 4 choices. How can I find out what the selection is (programmatically) and get the BOOL of it?
To find the selected radio button, you follow these steps: Select all radio buttons by using a DOM method such as querySelectorAll() method. Get the checked property of the radio button. If the checked property is true , the radio button is checked; otherwise, it is unchecked.
Get the value of selected radio button: querySelector() Remember you need to specify the name property of the radio button in HTML code. It is used as document. querySelector('input[name="JTP"]:checked') inside the <script> tab to check the selected radio button value from the group of radio buttons.
The radio button state represents a type attribute whose value is "radio" represents a selection of one item from a list of items (a radio button).
Assuming your matrix of radio buttons is named matrix
and is of type NSMatrix *
, you find the selected NSButton via NSMatrix's selectedCell
method and then access the button's state via NSButton's state
method, like this:
BOOL state = [[matrix selectedCell] state];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With