我有这段代码,提交后,它会从数组中生成随机数。
<?php
if(isset($_POST['roll'])) {
$randarray = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$randselect = array_rand($randarray);
$nr = $randarray[$randselect];
echo '<p class="btn btn-info"> Branch: '. $nr. '</p>';
}
?>
<form action="#" method="post">
<button type="submit" class="btn btn-default" name="roll">Roll Branch </button>
</form>
Run Code Online (Sandbox Code Playgroud)
我想做的是提交表单后,该按钮将被禁用。有什么想法吗?
disabled如果按下按钮,只需添加,例如
<button type="submit" class="btn btn-default" name="roll" <?php echo isset($_POST["roll"]) ? "disabled" : "";?>>Roll Branch </button>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9618 次 |
| 最近记录: |