Tuesday, September 25, 2012

Find selected item from radiobutton list using javascript

ASP.NET renders a table and a bunch of other mark-up around the actual radio inputs  

 var list = document.getElementById("rdbdesc"); 
    var inputs = list.getElementsByTagName("input"); 
    var selected;  
    for (var i = 0; i < inputs.length; i++)  
    {      
    if (inputs[i].checked) { 
    selected = inputs[i];     
    break;   
    }    
    }   
    if (selected)
    {
       
    alert(selected.value);   
   
    }
  

No comments:

Post a Comment