title: Use JavaScript to show warning message
body: <p>I am trying to show a warning message if the users select Yes from the radio button.  My issue is that the warning message is only showing Yes but i would like to show Yes and No so the user can select either of them. When they select Yes then i am deleting some records but all that is being done in the code behind.  What am i doing wrong here?</p>
  
  <pre><code>&lt;div&gt;
  
      &lt;asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" RepeatDirection="Horizontal"
          OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"&gt;
          &lt;asp:ListItem Value="0"&gt;Yes&lt;/asp:ListItem&gt;
          &lt;asp:ListItem Value="1" Selected="True"&gt;No&lt;/asp:ListItem&gt;
  
      &lt;/asp:RadioButtonList&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>here is the javascript</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      var selectlistId =   document.getElementsByName('&lt;%= RadioButtonList1.ClientID %&gt;');
      selectlist = document.getElementByid(selectlistId);
  
      selectlist.onchange = function () {
          if (selectlist.options[selectlist.selectedIndex].value == "YES") {
              if (confirm("Are you sure you want to delete?")) {
                  __doPostBack(selectlistId, '');
              } else {
                  // User selected NO, so change DropDownList back to 0.
                  selectlist.selectedIndex = 0;
              }
          }
      };
  &lt;/script&gt;
  </code></pre>