为.net里面的RadioButtonList添加选择事件

为了让根据选择的  RadioButtonList值不同,隐藏或显示一些页面上的信息

(比如,添加文章是选择次文章是否为转载,如果是转载的话,需要添加转载信息,如果不是,就隐藏这些信息)。

相关代码如下:

1.页面表格内容。

            <tr>
                <td>
                    来源:
                 </td>
                <td>
                    <asp:RadioButtonList ID="rblType" runat="server" 
                        RepeatDirection="Horizontal">
                        <asp:ListItem Value="0" Selected="True">原创</asp:ListItem>
                        <asp:ListItem Value="1">转载</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr class="fromInfo">
                <td>
                    作者:</td>
                <td>
                    <asp:TextBox ID="txtAuthor" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr class="fromInfo">
                <td>
                    转自:
                </td>
                <td>
                    <asp:TextBox ID="txtUrl" runat="server" Width="380px" 
                        MaxLength="500"></asp:TextBox>
                </td>
            </tr>

2.js相关代码,此处使用了Jqery

<script type="text/javascript">
        $(document).ready(function () {
            check();

            $(":radio").click(function () {
                check();
            });

        function check() {
            if ('1' == $(":checked").val()) {
                $(".fromInfo").show();
            } else {
                $(".fromInfo").hide();
            }
        }
        });
</script>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值