Here's a code that will change a dropdown menu with the ID of "106" to a null value if I change a radio button with the ID of "101" from one option to another:
<script type="text/javascript">
jQuery(document).ready(function($){
$('input[name="item_meta[101]"]').change(function(){
$('select[name="item_meta[106]"]').val('');
})
})
</script>
I need, however, to make 106 change to null only if a specific value in 101 is selected, but not just any available values. The values of the radio button id=101 are 1, 2, 3, 4, 5 respectively. So I want 106 to revert to null value if, say, 101 is changed from 5 to 4, but not from 5 to 3.
Is this possible? If so, it would obviously involved changing the ".change(function()" to some other param, but I don't know what it would be.
Thanks any advance for any help. Here's a JS Fiddle: http://jsfiddle.net/3N2TT/
UPDATE: Here's the final code that worked:
<script type="text/javascript">
jQuery(document).ready(function($){
$('input[type="radio"][name="item_meta[101]"]').change(
function () {
var valCheck = this.value === '4 Categories - $90';
$('select[name="item_meta[106]"]').val(function () {
return valCheck ? 'null' : this.value;
});
});
})
</script>
Thanks, David!