Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/403.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
Php getElementById不起作用的Javascript onclick_Php_Javascript_Html - Fatal编程技术网

Php getElementById不起作用的Javascript onclick

Php getElementById不起作用的Javascript onclick,php,javascript,html,Php,Javascript,Html,启用html文本框的简单onclick函数不起作用。。。单击文本框时不会发生任何事情。将变量用作id的一部分 <script language="JavaScript"> function unlock(id) { document.getElementById('strain'+id).disabled=false; return false; } </script> <input id="strain343" type="text

启用html文本框的简单onclick函数不起作用。。。单击文本框时不会发生任何事情。将变量用作id的一部分

<script language="JavaScript">

function unlock(id)
{
    document.getElementById('strain'+id).disabled=false;
    return false;
}

    </script>


<input id="strain343" type="text" value="54.24" onclick="return unlock(343);" disabled="true" name="strain"></input>

功能解锁(id)
{
document.getElementById('straint'+id).disabled=false;
返回false;
}

禁用的输入不会捕获单击事件

另见:

禁用的表单控件必须防止在用户交互任务源上排队的任何单击事件在元素上调度



您需要重新考虑您的UI,以避免元素被禁用或避免需要单击它。

禁用的输入不会捕获单击事件

另见:

禁用的表单控件必须防止在用户交互任务源上排队的任何单击事件在元素上调度



您需要重新考虑您的UI,以避免元素被禁用或避免需要单击它。

将您的输入包装到另一个块元素中;将onclick事件附加到该元素。

将输入包装到另一个块元素中;将onclick事件附加到该事件。

您不能“单击”已禁用的输入。但点击事件是由家长捕获的

    <div id="strainWrapper" onclick="unlock(343)">
        <input class="strainTB" id="strain343" type="text" value="54.24" disabled="true"></input>
    </div>
    <script>
        function unlock(id) {
            document.getElementById('strain' + id).disabled = false;
            return false;
        }
    </script>

功能解锁(id){
document.getElementById('straint'+id).disabled=false;
返回false;
}
您不能“单击”已禁用的输入。但点击事件是由家长捕获的

    <div id="strainWrapper" onclick="unlock(343)">
        <input class="strainTB" id="strain343" type="text" value="54.24" disabled="true"></input>
    </div>
    <script>
        function unlock(id) {
            document.getElementById('strain' + id).disabled = false;
            return false;
        }
    </script>

功能解锁(id){
document.getElementById('straint'+id).disabled=false;
返回false;
}

JS属于.JS文件,您不需要使用服务器端代码构建功能性JS。呈现的HTML是什么样子的?要么您的PHP没有生成您想要的JS/HTML,要么您正在生成的JS/HTML没有达到您期望的效果。确定那是什么。然后问一个关于如何让PHP生成您想要的JS的问题,或者一个关于如何让JS做您想要的事情的问题。不要向我们展示PHP并要求我们调试生成的JavaScript。另外,运行HTML,因为有一些错误。明白了。。。我编辑了这篇文章,只包含呈现的html。JS属于.JS文件,你永远不需要用服务器端代码构建功能性的JS。呈现的html是什么样子的?要么你的PHP没有生成你想要的JS/html,要么你正在生成的JS/html没有达到你期望的效果。确定那是什么。然后问一个关于如何让PHP生成您想要的JS的问题,或者一个关于如何让JS做您想要的事情的问题。不要向我们展示PHP并要求我们调试生成的JavaScript。另外,运行HTML,因为有一些错误。明白了。。。我编辑了这篇文章,只包含了呈现的html。很漂亮。。。我一辈子都搞不懂这个。我将尝试使用readonly而不是disabled。。。谢谢美丽的。。。我一辈子都搞不懂这个。我将尝试使用readonly而不是disabled。。。谢谢