Radio button to disable select ( 'else' not working)
This is what i have
<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.orde开发者_Go百科r.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/
the script doesn't work in html file. How to fix this ? here is the actual page im trying to get this to work http://icuretech.com/revision/iphone-3g-glass-repair.html
You don't have an input whose value is lose1
. You have lose
and 1
individually as values for certain inputs, but not both, so that expression will never evaluate to what you want it.
<script src="prototype.js"></script>
<script src="jquery.js"></script>
<script>
$('input:radio[name="RADIOSELECTOR"]').change(function() {
if ($(this).val()=='one') {
$('#ones').removeAttr('disabled');
$('#twos').attr('disabled',true);
} if ($(this).val()=='two') {
$('#ones').attr('disabled',true);
$('#twos').removeAttr('disabled');
} if ($(this).val()=='lose') {
$('#ones').attr('disabled',true);
$('#twos').attr('disabled',true);
}
if ($(this).val()=='lose1') {
$('#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">
<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" ><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>
精彩评论