我有一个困扰我好几天的问题——当复选框处于打开或关闭状态时,我试图将一个变量附加到一个选项值中。变量正在显示,但不是我想要的方式,我希望在复选框关闭时将“无订阅”附加到选项值中,并且在复选框打开时将“订阅”附加到选项值中。这是我的脚本:
<?php
if(isset($_POST['subscribe']) == '1') {
$sub = ", Subscribe";
} else {
$sub = ", No Subscription";}
?>
--------------------------------------------------------------------------------------------
<form class="cart" action="http://serber.com" method="post">
<section class="clear"></section>
<label>Tampons (Non-Applicator) Regular : </label>
<select name="productpr">
<option value="NT12<?php printf($sub); ?>:17.95">1 Month - $17.95 <span></span> </option>
<option value="NT12 3 Months<?php printf($sub); ?>:33.85">3 Months - $33.85</option>
<option value="NT12 6 Months<?php printf($sub); ?>:57.70">6 Months - $57.70</option>
</select>
<input type="hidden" name="submitted" value="true" />
<br /><input type="submit" value="Add to Cart">
<input type="hidden" name="subscribe[]" value="0" />
<input type="checkbox" name="subscribe[]" value="1">Check Box if you wish to have a recurring subscription</input>
</form>
I am at my wit's end with this because it seems I have the isset correct but the checkbox value
没有被设置。