我在下面包含了我的两个代码源。
我遇到的问题是,如果您单击其中一个单选按钮(单选按钮组是按钮组的ID),则先前“已选中”选项不会取消选择,并且新的“已选中”选项会没有被选中。相反,会发生选择器点击事件,“已检查”选项保持不变。
我该如何解决这个问题?我已经尝试在“选中”新选项时清除“已检查”选项,然后通过Javascript检查该选项,但我没有取得任何成功。
思想?
谢谢!
Javascript代码:
$(function() {
$("#paid-content-box").hide();
$("#general-settings").show();
$("#individual-box-prices").hide();
$("#paypal-preference").hide();
$("#general-settings-link a").click(function() {
$("#paid-content-box").hide();
$("#general-settings").show();
return false;
});
$("#paid-content-settings-link a").click(function() {
$("#paid-content-box").show();
$("#general-settings").hide();
return false;
});
$("input#somepaid").click(function() {
document.forms['paidContentForm'].elements['perbox'].disabled = true;
$("#individual-box-prices").show();
$("#paypal-preference").show();
return false;
});
$("input#allfree").click(function() {
document.forms['paidContentForm'].elements['perbox'].disabled = true;
$("#individual-box-prices").hide();
$("#paypal-preference").hide();
return false;
});
$("input#subscription").click(function() {
document.forms['paidContentForm'].elements['perbox'].disabled = false;
$("#individual-box-prices").hide();
$("#paypal-preference").show();
return false;
});
});
HTML / PHP代码:
<div id="paid-content-box" align="left">
<form name="paidContentForm" action="" method="post">
<h2>Set Your group / Box Prices</h2>
<div id="radio-group" class="radiogroup">
<input id="allfree" type="radio" name="boxprices" value="allfree" checked><label for="allfree">All boxes are free.</label><br />
<input id="subscription" type="radio" name="boxprices" value="subscription"><label for="subscription">Subscription pricing (all paid).</label>
<label for="perbox">Enter price per box: $</label><input id="perbox" type="text" name="subscriptionpriceper" disabled="true"><br />
<input id="somepaid" type="radio" name="boxprices" value="somepaid"><label for="somepaid">Some of the boxes are free and some our paid content. (Please set the price for each box in the textboxes that will appear below.)</label>
</div>
<div id="individual-box-prices">
<h3>Set Individual Box Prices</h3>
<table id="pricetable">
<tr>
<th>Box Name</th>
<th>Free/Paid</th>
<th>Price</th>
</tr>
<? foreach($boxInfo as $newBox){ ?>
<tr>
<td><? echo $newBox['name']?></td>
<td><span id="box_<? echo $newBox['id']?>_free">Free</span> | <span id="box_<? echo $newBox['id']?>_paid"><a href="javascript:freePaidOption(<? echo $newBox['id']?>, 'paid')">Paid</a></span></td>
<td><label for="box_<? echo $newBox['id']?>_price">$</label><input id="box_<? echo $newBox['id']?>_price" type="text" name="box_<? echo $newBox['id']?>_price" value="" disabled="true"></td>
</tr>
<input type="hidden" name="defaultFreePaid_<? echo $newBox['id']?>" value=""/>
<? } ?>
</table>
</div>
<div id="paypal-preference">
<h3>Payment Preferences</h3>
<label for="paypalemail">Enter your PayPal account email address:</label><input type="text" id="paypalemail" name="paypalemail">
</div>
<br /><br />
<input type="submit" name="SavePaidContent" value="Save" class="inputText">
</form>
</div>
答案 0 :(得分:0)
您的所有事件处理程序都返回false。这会阻止默认操作,即更改选定的单选按钮。