<script type="text/javascript">
$('input:radio[name="RADIOSELECTOR"]').change(function() {
if ($(this).val()=='one') {
$('#ones').removeAttr('disabled');
$('#twos').attr('disabled',true);
} else if ($(this).val()=='two') {
$('#ones').attr('disabled',true);
$('#twos').removeAttr('disabled');
} else {
$('#ones').attr('disabled',true);
$('#twos').attr('disabled',true);
}
});
</script>
<form name="order" action="managecart.html" onsubmit="return AddToCart(this); return ValidateCart(this);">
<input name="PRICE" type=hidden id="PRICE" value="" />
<input name=NAME type=hidden id="NAME" value="" />
<input name=ID_NUM type=hidden id="ID_NUM" value="" />
<input type=hidden name="SHIPPING" value="0.00" />
<input type="radio" name="RADIOSELECTOR" value="lose" onClick="document.order.PRICE.value='59.99'; document.order.NAME.value='iPhone 3G Glass/digitiazer replacement'; document.order.ID_NUM.value='3GGL'; document.order.SHIPPING.value='0.00';" />Glass/digitizer repair <b>59.99$</b><br><br>
<b> Combo repairs:</b><BR><br>
<input type="radio" name="RADIOSELECTOR" value="lose" onClick="document.order.PRICE.value='74.99'; document.order.NAME.value='iPhone 3G Glass/digitizer + battery repair'; document.order.ID_NUM.value='3GGLB'; document.order.SHIPPING.value='0.00';" />Glass/digitizer + battery repair = <b> 74.99$</b> 25$ in savings!<br>
<input type="radio" name="RADIOSELECTOR" value="one" onClick="document.order.PRICE.value='79.99'; document.order.NAME.value='iPhone 3G Glass/digitizer + combo '; document.order.ID_NUM.value='3GGLC'; document.order.SHIPPING.value='0.00';" />Glass/digitizer + <select id="ones" name="ADDITIONALINFO2" disabled="disabled">
<option value=" "></option><option value="Home button">Home button</option> <option value="Power button">Power button</option><option value="Mute switch">Mute switch</option><option value="volume button">Volume button</option></select>
= <b>79.99$</b> 30$ in savings!<br>
<input type="radio" name="RADIOSELECTOR" value="two" onClick="document.order.PRICE.value='99.99'; document.order.NAME.value='iPhone 3G Glass/digitizer + combo + ''ADDITIONALINFO3'; document.order.ID_NUM.value='3GGLBC'; document.order.SHIPPING.value='0.00';" />Glass/digitizer + battery + <select name="ADDITIONALINFO3" id="twos" disabled="disabled"><option value=" "></option><option value="Home button">Home button</option> <option value="Power button">Power button</option><option value="Mute switch">Mute switch</option><option value="volume button">Volume button</option></select> = <b>99.99$</b> 30$ in savings!<br>
<input name="QUANTITY" type="hidden" value="1" /><br>
<input type="image" src="./images/addtocart.png" align="center" name="BUY" value=" Add to cart " ALT="Add to Cart">
</form>
DEMO http://jsfiddle.net/uSmVD/86/
腳本不會在HTML文件中工作。如何解決這個問題? 這裏是實際的頁面即時試圖讓這個工作http://icuretech.com/revision/iphone-3g-glass-repair.html
你可以用適當的縮進格式化你的代碼,使其清晰? – 2011-04-22 03:02:44
http://jsfiddle.net/uSmVD/79/這就是發生什麼 – Rafal 2011-04-22 03:24:47
因爲中間塊應該使用'else if',而不是'if'。給[this](http://homepage.ntlworld.com/kayseycarvey/controlflow3.html)一讀。 – 2011-04-22 03:31:53