【问题标题】:Hide/Show Radio Button List Item using javascript使用javascript隐藏/显示单选按钮列表项
【发布时间】:2013-03-28 03:24:08
【问题描述】:

我有一个下拉列表,比如 ddlTest,其中包含 Opt1、Opt2 作为项目。在同一页面上,我有一个单选按钮列表,列表项为 rblItem1、rblItem2 和 rblItem3。现在,如果用户在下拉列表中选择 Opt2,那么我应该隐藏 rblItem3 或对于选择的任何其他选项,我应该在单选按钮列表中显示 rblItem3。

能否请您告诉我是否可行以及如何使用 javascript 来实现。

【问题讨论】:

    标签: c# javascript asp.net drop-down-menu radiobuttonlist


    【解决方案1】:
    <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-28
      • 1970-01-01
      • 2012-06-12
      • 1970-01-01
      • 1970-01-01
      • 2013-07-06
      相关资源
      最近更新 更多