如何在if条件中禁用按钮 [英] How to disable button in an if condition
本文介绍了如何在if条件中禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果prod_quantity == 0,我该如何禁用一个按钮?
How do i disable a button if the prod_quantity == 0?
<?php
$prod_qty = $row['prod_quantity'];
if ($prod_qty == '0'){
echo "<h1>sold out</h1>";
}
?>
这里是我需要禁用的按钮,当prod_qty == 0
and here is the button that i need to be disabled when prod_qty == 0
<input type="button" value="Add to Cart" onclick="addtocart(<?php echo $row["prod_id"]?>)" />
推荐答案
如果 $ prod_qty =='0'
类似于code>条件来设置属性为 disabled
如下所示:
Add an if
condition to the button to set the property as disabled
if $prod_qty == '0'
like shown below :
<input type="button" value="Add to Cart" <?php if ($prod_qty == '0'){ ?> disabled <?php } ?> onclick="addtocart(<?php echo $row["prod_id"]?>)" />
这篇关于如何在if条件中禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文