本文介绍了如何启用和禁用服务器到客户端的复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai

如何在服务器端和客户端启用和禁用复选框。



i想在页面提交时禁用复选框如果我点击但是从表单中它将启用复选框。我的问题是,在设计时间和页面加载事件中我写了一个代码,如

Hai
How to enable and disable checkbox from server server side and client side.

i want to disable check boxex when page laod after if i click but from form it will enable check box.my problem is ,in design time and page load event i write a code like

chkPPT.Enabled = False

当按钮单击时,我会编写启用代码复选框,如

and when button click even i write code for enable check box like

var chkPdf = document.getElementById('<%=chkPdf.ClientID%>');
            chkPdf.disabled = false;  or document.getElementById("ctl00_ContentPlaceHolder1_chkPdf").disabled = false;

但不行。





从服务器端禁用并尝试启用时会出现什么问题在java脚本中不起作用,但第二次它将从客户端禁用并可以在客户端启用。



注意:复选框之间没有span标记





请尽快回复我





其实我是想从页面加载事件中禁用三个复选框,需要在客户端启用按钮onclient点击事件(java脚本)。



Reagards

Aravind

but not work.


what problem when disable from server side and try to enable in java script not work,but second time it will disable from client side and can enable in client side.

Note : no span tag between check boxs


Pls reply me asap


Actually i want disable three check boxes from page load event and need to enable from client side in button onclient click event(java script).

Reagards
Aravind

推荐答案

<asp:CheckBox runat="server" ID="CheckBox1"></asp:CheckBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="ChkEnabled(); return false;" />




<script language="javascript" type="text/javascript">
  function ChkEnabled(){
        var a = document.getElementById('<%=CheckBox1.ClientID %>');
         a.removeAttribute('disabled');
        a.parentNode.removeAttribute('disabled');
    }
</script>



在Page_Load中禁用:


To disable in Page_Load:

CheckBox1.Enabled = false;



问候..:)


Regards..:)


window.onload = function disablecheckbox() {
         document.getElementById("ctl00_ContentPlaceHolder1_chka").disabled = true;
         document.getElementById("ctl00_ContentPlaceHolder1_chkb").disabled = true;
         document.getElementById("ctl00_ContentPlaceHolder1_chkc").disabled = true;
         document.getElementById("ctl00_ContentPlaceHolder1_chkd").disabled = true;
         document.getElementById("ctl00_ContentPlaceHolder1_chke").disabled = true;
         document.getElementById("ctl00_ContentPlaceHolder1_btnsave").disabled = true;
     }









问候

Aravind





Regards
Aravind


这篇关于如何启用和禁用服务器到客户端的复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 04:39