Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
27
rated 0 times [  29] [ 2]  / answers: 1 / hits: 36155  / 14 Years ago, fri, july 9, 2010, 12:00:00

I have a few radio buttons that belong to the same category, but I want to name them differently and make them mutually exclusive. How do I do that? Based on the selected value, I do different actions, and I can't access them if they have the same name.


More From » html

 Answers
7

Why can't you access them if they have the same name? You can add IDs (you should), you can distinguish by value or just count them and use the n-th element.



You should give radiobuttons the same name to make the browser understand they are exclusive.



You could (but should not) hack around this, and give each object a different name. Then add an onSelect/onClick handler for each object, and when the event fires, uncheck the other buttons. This is dirty and should be avoided.


[#96284] Wednesday, July 7, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jameson

Total Points: 534
Total Questions: 103
Total Answers: 102

Location: Lithuania
Member since Fri, Sep 4, 2020
4 Years ago
jameson questions
;