Let’s say I have three radio buttons:
RA, RB, RC
On each change value event, I run a method.
Now, if I select RB and RA was previously selected, it will run once for when RB is selected, and RA is unselected. Is there any way to prevent this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming that you only want the method to run once at all, just have a flag which determines if the method has run at all and only run the method if the flag is not set and set the flag on the first run.
If you want the method only to run once for each change you could probably keep track of the current selected radio button and only run the method if the current selected radio button is different from the last one you know you ran the method for, and switch the current one in the method. So at first the selected one would be null, then the first time the method is run you would set it to the selected item, when the method ran the next time the current one would be the same as the selected one so you skip the method. When you then switch the radio button the first time the selected one would be different to the current one so you would run it, and set the current to the selected. the next time the method is invoked the current would be the same as the current so it would be skipped.