title: Get the value from radiobuttonlist through javascript?
body: <p>I have a radibutton list.</p>
  
  <pre><code>          &lt;asp:RadioButtonList ID="RadioButtonList1" runat="server" 
                RepeatDirection="Horizontal" RepeatLayout="flow" &gt;
               &lt;asp:ListItem Selected="True" Text ="Yes" Value="0"&gt;&lt;/asp:ListItem&gt;
               &lt;asp:ListItem  Text ="No" Value="1"&gt;&lt;/asp:ListItem&gt;
            &lt;/asp:RadioButtonList&gt;
  </code></pre>
  
  <p>And to get the value from radio list I have a function :</p>
  
  <pre><code> function getvalueofradiolist() {
  
          var radiolist = document.getElementById('&lt;%= RadioButtonList1.ClientID %&gt;');
          var rblName = radiolist.name;
          var radio = document.getElementsByName(rblName);
  
          for (var x = 0; x &lt; radio.length; x++) {
              if (radio[x].checked) {
                  alert("Selected item Value " + radio[x].value);
              }
          }
      }
  </code></pre>
  
  <p>But it returns undefined.</p>
  
  <p>Did I write something wrong?</p>
  
  <p>I am calling this function on button click.</p>
  
  <p>Suggest me If I can do this with the help of code behind in spite of Javascript.</p>