Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends... Can any one tell me how to assign color to a radiobutton-text of a RadioButtonList using javascript?
Iam getting the particular radio buttons as below..
JavaScript
for (i = 0; i < document.forms[0].elements.length; i++) {
                elm = document.forms[0].elements[i];
                if (elm.type == 'radio') {
                    if (elm.checked) { cmpIdRange = elm.value; break; }
                }
            }

I tried like this..
JavaScript
document.getElementById(elm.id).style.color = "green";

But im not getting the result... Please tell me any solution.

Thanks in advance...
Posted
Updated 8-Jan-12 20:17pm
v4

1 solution

Hi
try the following

<asp:RadioButton ID="rbtnTest" runat="server" onclick="changecolor(this);" />


Javascript:
C#
function changecolor(ctrl) {
         ctrl.style.backgroundColor = "Red";
ctrl.nextSibling.style.color= "Orange";
     }
 
Share this answer
 
v2
Comments
Venkat_C6 9-Jan-12 2:18am    
Hi... If I tried Like this it affecting the background color of radio button but not its text...
sriman.ch 9-Jan-12 22:05pm    
Have a look on my solution...I made some change.....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900