读书人

小弟我的表单只能在火狐上提交

发布时间: 2012-12-30 10:43:15 作者: rapoo

我的表单只能在火狐下提交
<form name="name" action="a.php" method="get">
<input type="text" name="abbb" value="" />
<input id="ab" type="submit" name="submitform" onclick="return checkform()" value="提交" />
</form>

<script type="text/javascript">
function checkform() {
document.getElementById("ab").disabled = "disabled";
return true;
}
</script>

上面的代码只能在火狐下工作,其它浏览器都不能提交,提交按钮变灰之后就没有动静了
如果使用jquery,把“document.getElementById("ab").disabled="disabled"改成“$("#ab").disabled="disabled"”就没有问题了。
问题是,为什么用document.getElementById就不行呢?
请问有谁可以帮我找到是什么原因吗?
[解决办法]
document.getElementById("ab")[0].disabled = "disabled";
这样就好了。。。。。
[解决办法]
我觉得你要先提交然后再禁用按钮
[解决办法]
楼主的方法不好,用这种

<form name="name" action="a.php" method="get" onsubmit="return checkform()">
<input type="text" name="abbb" value="" />
<input id="ab" type="submit" name="submitform" value="提交" />
</form>

<script type="text/javascript">
function checkform() {
document.getElementById("ab").disabled = "disabled";
return true;
}
</script>

[解决办法]
    function checkform() {
document.getElementById("ab").disabled = "disabled";
document.name.submit()
return true;
}

读书人网 >JavaScript

热点推荐