Hi,
Is there a way for some options in a dropdown list/checkboxes to be greyed out (not temporarily removed), based on what the user selects in a previous radio buttons field?
Thanks
You can do this with JS or jQuery.
You can disable any option in a dropdown by adding the 'disabled' attribute to it and you can do this conditionally with jQuery quite easily.
There isn't an example of this in the FF KB but there are some other examples that you could combine & edit to achieve what you need.
https://formidableforms.com/knowledgebase/javascript-examples/
Thanks - would this work for just greying it out (ie the user can still see the option but cannot select it) or would it mean they can't see the option altogether?
<p>Yes this would mean users can still see the option but it would be greyed out and can't be selected.</p>
Thanks
This basic example will get the value from a Radio Button field and disable the same value in a dropdown.
Change 804 to the field ID of the radio button and ht4d3 to the field KEY of the dropdown.
<script>
jQuery(document).ready(function($){
$('input[name="item_meta[804]"]').change(function(){
var val1 = $(this).val();
$("#field_ht4d3 option:contains('" + val1 + "')").attr("disabled","disabled");
$("#field_ht4d3 option:not(:contains('" + val1 + "'))").removeAttr("disabled","disabled");
});
});
</script>
Please login or Register to submit your answer