I found myself sitting at the laptop at 10:00 on a Sunday night, thinking about a request that the boss had for one of my apps. This past week, he asked "What if you accidentally click on a radio control, you want to deselect what you clicked, and you don't want to refresh the webpage? What do you do, then?" After two "Dunkin' Pumpkin" beers, I figured that it would be an interesting challenge to think about.
With some onClick magic and a variable to hold the value prior to the click event, it is just a matter of writing an if/else statement for each of the radio controls.
In the above example, the first set is a demonstration of the default behavior. The second set is with the new, modified behavior.
So, what do you think? Let me know in the comments if you have an easier method.
Top comments (0)