【发布时间】:2021-07-05 14:59:41
【问题描述】:
我被困在这个问题上。
我有两个单选按钮。一个是Buyer,第二个是Seller。
<input type="radio" name="account_type" value="1" id="acc_buyer" checked="checked">Buyer
<input type="radio" name="account_type" value="2" id="acc_seller">Seller
Buyer 单选按钮已被选中。
现在我要做的是,我有下面的代码,如果$account_type==2 那么我必须选择seller 单选按钮并取消选中买家。
我试过下面的代码
if(isset($_SESSION['error'])){
$error = $_SESSION['error'];
$account_type = $_SESSION['account_type'];
unset($_SESSION['account_type']);
unset($_SESSION['error']);
}
<input type="radio" name="account_type" value="1" id="acc_buyer" checked="checked"> Buyer
<input type="radio" name="account_type" value="2" id="acc_seller" <?php if(isset($account_type) && $account_type=='2') { ?> checked="checked" <?php }?>> Seller
【问题讨论】:
-
您在两个单选按钮上都放置了
checked。如果它们依赖于一个值,那么它们都应该基于一个条件输出。 -
@El_Vanja,你是对的,但我无法取消选中买家。你能帮我解决这个问题吗?