此代码“有效” - 该按钮已禁用且表单已提交。快乐的日子。
<form action="timestable_update.php">
<input type="submit" value="Bank Your Score" name="submitbtn" onclick="this.disabled=true; this.form.submit();">
</form>
此代码不起作用(我正在查看id =“btn”按钮)...所有发生的事情是按钮禁用,但没有提交发生......
<form method= "post" action="timestable_submit.php">
<input type="hidden" name=b value=<?php echo $f;?>>
<input type="hidden" name=c value=<?php echo $s;?>>
<input type="submit" name="submit" id="btn" value="<?php echo $d;?>" onclick="this.disabled=true; this.form.submit();">
<input type="submit" name="submit" id="btn2" value="<?php echo $w1e;?>">
<input type="submit" name="submit" id="btn3" value="<?php echo $w2e; ?>">
</form>
关于为什么的任何想法?
这是完整的代码......
<html>
<head>
<!--------------timer---------------->
<script type="text/javascript">
var interval;
var minutes = 0;
var seconds = 05;
window.onload = function () {
countdown('secondsleft');
}
function countdown(element) {
interval = setInterval(function () {
var el = document.getElementById(element);
if (seconds == 0) {
el.innerHTML = "Time is Up!";
window.location.assign("timestable_timeout.php")
if (minutes == 0) {
clearInterval(interval);
return;
} else {
minutes--;
seconds = 60;
}
}
el.innerHTML = seconds;
seconds--;
}, 1000);
}
</script>
<!------------------ timer end ------------>
<style>
input[type='submit']{
position: absolute;
width: 300;
height: 50;
color: white;
background: red;
font-size:100%;
}
</style>
</head>
<body>
Level: 1<br>Staff, your score so far is: 0
<br>Click on the answer to: 2x11
<form method= "post" action="timestable_submit.php">
<input type="hidden" name="b" value="2">
<input type="hidden" name="c" value="11">
<input type="submit" name="submit" id="btn" value="22" onclick="this.disabled=true; this.form.submit();">
<input type="submit" name="submit" id="btn2" value="100">
<input type="submit" name="submit" id="btn3" value="30">
</form>
<!------ timer----->
<h1><div id="secondsleft"></div></h1>
<script>
var btn = document.getElementById("btn");
btn.style.top = 553+ "px";
btn.style.left = 408 + "px";
var btn2 = document.getElementById("btn2");
btn2.style.top = 452+ "px";
btn2.style.left = 290 + "px";
var btn3 = document.getElementById("btn3");
btn3.style.top = 503+ "px";
btn3.style.left = 542 + "px";
</script>
</body></html>
答案 0 :(得分:0)
问题在于第二个按钮上的name="submit"
属性。这会导致Chrome出现问题,因为它会覆盖您表单的submit()
函数,从而导致FirstOne在其评论中发现错误:
Uncaught TypeError: this.form.submit is not a function
如果您选择其他名称(就像您为第一个按钮所做的那样),那么它应该可以正常工作。