Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get state of radio button and whether it is selected?

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?

like image 602
ProSay Avatar asked Jul 03 '11 14:07

ProSay


People also ask

How do I check if a radio button is selected?

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.

How do you get a radio button state?

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.

What is the state of a radio button?

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).


1 Answers

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];
like image 77
hbw Avatar answered Oct 05 '22 14:10

hbw