当我取消选中java脚本中表单视图中的复选框时,如何隐藏面板 [英] How to hide the panel when i uncheck the check box which is in form view in java script

查看:79
本文介绍了当我取消选中java脚本中表单视图中的复选框时,如何隐藏面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上我在一个面板中有两个文本框,在formview1中,复选框也在formview1中,当我选中复选框时,它应该显示面板取消选中意味着它应该隐藏面板这个功能我在.cs页面在checkbox_checked事件但现在我不想回发这个。所以我需要javascript代码这个



//下面是我的代码

Actually i am having two text boxes in one panel which is in formview1 and checkbox is also in formview1 when i check the check box it should display the panel uncheck means it should hide the panel this functionality i am doing in .cs page in checkbox_checked event but now i dont want to postback for this .so i need javascript code for this

//below is my code

<asp:CheckBox ID="chkReceiveMobileNotification" runat="server"   Enabled="true"

                                                          oncheckedchanged="chkReceiveMobileNotification_CheckedChanged"

                                                          AutoPostBack="True"  />
                                                  </div>
                                                  <asp:Panel ID="PanelEnableMobileNotifications" runat="server">
                                                  <div class="sepH_b">
                                                <label for="Allergen" class="lbl_a"  style="width:300px">Mobile Notification Time Range</label>
                                                   <asp:TextBox ID="txtMobilNotMin" runat="server" CssClass="inpt_a" Text='<%# Bind("NotifTime") %>' />
                                                </div>

                                                <div class="sepH_b">
                                                <label for="Allergen" class="lbl_a"  style="width:300px">Mobile Notification Count</label>
                                                   <asp:TextBox ID="txtMobilNotCount" runat="server" CssClass="inpt_a" Text='<%# Bind("NotifCount") %>' />
                                                </div>
                                                </asp:Panel>

推荐答案

您好Ntitish,



请使用jQuery参考以下链接。

jsfiddle [ ^ ]



这样做在jQuery中也可以用JavaScript完成。如果你只是JS,请告诉我。



Hi Ntitish,

Please refer to the below link for doing it using jQuery.
jsfiddle[^]

This is done in jQuery and can also be done in JavaScript. Let me know if you are only into JS.

<script>
    function hideshow(obj) {
        if (obj.checked) {
            alert('hide');
            document.getElementById('<%=PanelEnableMobileNotifications.ClientID %>').style.display = 'none';
        }
        else {
            alert('show');
            document.getElementById('<%=PanelEnableMobileNotifications.ClientID %>').style.display = 'inline';
        }
    }
</script>





HTML复选框代码如下所示





And the HTML checkbox code looks like the below

<asp:CheckBox ID="chkReceiveMobileNotification" runat="server"   Enabled="true" onclick="hideshow(this)"  />





谢谢,

Vamsi



Thank you,
Vamsi


这篇关于当我取消选中java脚本中表单视图中的复选框时,如何隐藏面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆