Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/445.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如果在aspx页面中使用javascript启用复选框,则需要启用按钮_Javascript_Asp.net - Fatal编程技术网

如果在aspx页面中使用javascript启用复选框,则需要启用按钮

如果在aspx页面中使用javascript启用复选框,则需要启用按钮,javascript,asp.net,Javascript,Asp.net,如果在aspx页面中使用javascript启用复选框,则需要启用按钮。这是我在aspx页面中的代码。请帮忙 <script type="text/javascript"> function checkButt(obj) { alert("Inside the function"); document.getElementById('<%=btnLoadForm.ClientID%>').disabled = !obj.checked; } 功能检查对

如果在aspx页面中使用javascript启用复选框,则需要启用按钮。这是我在aspx页面中的代码。请帮忙

<script type="text/javascript">
function checkButt(obj) {
    alert("Inside the function");
    document.getElementById('<%=btnLoadForm.ClientID%>').disabled = !obj.checked;
}

功能检查对接(obj){
警报(“功能内部”);
document.getElementById(“”).disabled=!obj.checked;
}

而不是:

document.getElementById('<%=btnLoadForm.ClientID%>').disabled = !obj.checked;
如果
disabled
是一个布尔属性,则该值没有多大区别。您可以在类似的帖子中阅读更多信息:

更新:

您需要围绕
removeAttribute
语句的逻辑。类似于:

function checkButt(obj) {
    if(obj.checked)
      document.getElementById('<%=btnLoadForm.ClientID%>').removeAttribute("disabled");
}
功能检查对接(obj){
如果(对象已选中)
document.getElementById(“”).removeAttribute(“禁用”);
}
这将启用
document.getElementById(“”)
如果选中了
obj.checked

而不是:

document.getElementById('<%=btnLoadForm.ClientID%>').disabled = !obj.checked;
如果
disabled
是一个布尔属性,则该值没有多大区别。您可以在类似的帖子中阅读更多信息:

更新:

您需要围绕
removeAttribute
语句的逻辑。类似于:

function checkButt(obj) {
    if(obj.checked)
      document.getElementById('<%=btnLoadForm.ClientID%>').removeAttribute("disabled");
}
功能检查对接(obj){
如果(对象已选中)
document.getElementById(“”).removeAttribute(“禁用”);
}

这将启用
document.getElementById(“”)
如果选中了
obj.checked

删除复选框的
AutoPostBack=“true”

在脚本中添加事件,而不是
内联HTML

<asp:Button runat="server" id="btnLoadForm" />
​<asp:CheckBox runat="server" id="chk" />​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

删除复选框的
AutoPostBack=“true”

在脚本中添加事件,而不是
内联HTML

<asp:Button runat="server" id="btnLoadForm" />
​<asp:CheckBox runat="server" id="chk" />​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

使用以下代码,您将获得解决方案

Javascript

<script type="text/javascript">

    function enableordisable() {
            if (document.getElementById('CheckBox1').checked == true) {
                document.getElementById('Button1').disabled = false;
            }
            else {
                document.getElementById('Button1').disabled = true;
            }
    }

函数enableOrdinable(){
if(document.getElementById('CheckBox1')。checked==true){
document.getElementById('Button1')。disabled=false;
}
否则{
document.getElementById('Button1')。disabled=true;
}
}

HTML






使用以下代码,您将获得解决方案

Javascript

<script type="text/javascript">

    function enableordisable() {
            if (document.getElementById('CheckBox1').checked == true) {
                document.getElementById('Button1').disabled = false;
            }
            else {
                document.getElementById('Button1').disabled = true;
            }
    }

函数enableOrdinable(){
if(document.getElementById('CheckBox1')。checked==true){
document.getElementById('Button1')。disabled=false;
}
否则{
document.getElementById('Button1')。disabled=true;
}
}

HTML






复选框是否将自动回邮设置为true复选框是否将自动回邮设置为true此项有效@user1718398-查看上面的更新是否使事情更清楚。@user1718398-查看上面的更新是否使事情更清楚。