提交PHP后禁用按钮 [英] Disable button after submit PHP
本文介绍了提交PHP后禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<?php $ b $这个代码在提交时会从数组中产生随机数。 b
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>分支:'。 $ NR。 < / p为H.;
}
?>
< form action =#method =post>
< button type =submitclass =btn btn-defaultname =roll> Roll Branch< / button>
< / form>
我想要做的是在表单提交后,按钮将被禁用。任何想法?
解决方案
如果按下按钮,只需添加 disabled
例如
< button type =submitclass =btn btn-defaultname =roll<?php echo isset($ _ POST [roll])? disabled:;?>>滚动分支< /按钮>
I have this code that when submitted, it generates random number from the array.
<?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>
What I wanted to do is after the form was submitted, the button will be disabled. Any thoughts?
解决方案
Just add disabled
if the button is pressed, e.g.
<button type="submit" class="btn btn-default" name="roll" <?php echo isset($_POST["roll"]) ? "disabled" : "";?>>Roll Branch </button>
这篇关于提交PHP后禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文