This is a migrated thread and some comments may be shown as answers.

RadioButtonList selected item using javascript

0 Answers 272 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
bharat kumar
Top achievements
Rank 1
bharat kumar asked on 15 Apr 2010, 02:30 PM

Hi
i have one RadioButtonList as below...

 

<asp:RadioButtonList id="rblType" runat="server"

 

 

style="z-index: 103; left: 465px; position: absolute; top: 120px;

 

 

width: 150px; height: 16px; vertical-align: middle;"

 

 

RepeatDirection="Horizontal" AutoPostBack="false"

 

onmousedown

 

="getCheckedRadio()"

 

 

 

 

 

 

 

OnSelectedIndexChanged="rblType_SelectedIndexChanged">

 

 

 

<asp:ListItem Text="St" Value="St" Selected="True"></asp:ListItem>

 

 

<asp:ListItem Text="TC" Value="TC"></asp:ListItem>

 

 

 

</asp:RadioButtonList>

now i want to change the text of textbox using the selected lsititem in radiobuttonlist using javascript.

 

function getCheckedRadio()
{

    var rblType= document.getElementsByName("ctl00_messagePanelsContent_contentPlaceHolder_fvAllotmentDetail_rblType");
//some loop here on rblType and then 
for(int i=0; i < rblType.length; i++ )
{
    if (rblType.item[i] == "checked")
      {       
            alert("You checked ");
        }
}
   
}

but the above javascript code is not working.
could anyone please help me to how to get the selected listitem using javascript.
thanks in advance...

waiting for reply.

No answers yet. Maybe you can help?

Tags
ComboBox
Asked by
bharat kumar
Top achievements
Rank 1
Share this question
or