2013-03-27 146 views
-1

我有一个下拉列表,说ddlTest,它有Opt1,Opt2作为项目。在同一页面上,我有一个单选按钮列表,列表项为rblItem1,rblItem2和rblItem3。现在,如果用户在下拉列表中选择Opt2,那么我应该隐藏rblItem3或选择其他选项,我应该在单选按钮列表中显示rblItem3。使用javascript隐藏/显示单选按钮列表项目

你能告诉我,如果这是可能的,以及如何使用JavaScript。

回答

0
<table> 
    <tr> 
     <td> 

       <asp:RadioButtonList ID="radiobuttonlist1" runat="Server" RepeatLayout="flow" RepeatDirection="horizontal"> 
         <asp:ListItem Text="Radio 1" Value="1" Selected="True"></asp:ListItem>  
          <asp:ListItem Text="Radio 2" Value="2"></asp:ListItem> 

          <asp:ListItem Text="Radio 3" Value="3"></asp:ListItem> 

            </asp:RadioButtonList> 

           </td> 

           <td> 

            <input type="button" value="Submit" onclick="GetRadioButtonValue('<%= radiobuttonlist1.ClientID %>')" /> 

           </td> 

          </tr> 

         </table> 

的JavaScript代码: -

<script language="javascript" type="text/javascript"> 

     // Get radio button list value 

     function GetRadioButtonValue(id) 

     { 

      var radio = document.getElementsByName(id); 

      for (var j = 0; j < radio.length; j++) 

      { 

       if (radio[j].checked) 

        //make hide the Item 

      } 

     } 

</script>