PHP
<?php
echo '<form method="POST" action="" onsubmit="return checkForm(this);">
<input type="submit" class="test1" name="myButton" value="Submit">
<input type="submit" class="test1" name="myButton" value="Submit">
<input type="submit" class="test1" name="myButton" value="Submit">
</form>';
if (isset($_POST['myButton'])) {echo 'Hey!';}
?>
的Javascript
<script type="text/javascript">
function checkForm(form) // Submit button clicked
{
var elems = document.getElementsByClassName("test1");
for(var i = 0; i < elems.length; i++) {
elems[i].disabled = true;
}
}
</script>
上面的脚本允许我在表单提交时禁用所有3个按钮,以防止在页面刷新之前多次提交。但是,表单提交没有通过(即'嘿'没有被回应)
有解决方法吗?