Show / Hide Radio Button Option

By: Chris Adams | Asked: 06/18/2021
ForumsCategory: Code SnippetsShow / Hide Radio Button Option
Chris AdamsChris Adams asked 3 years ago
This snippet will show / hide a radio button option based on another radio button value.  
<script>
jQuery(document).ready(function ($) {
	// Hide field by default
	var hideme = $("#frm_radio_1831-1786-0");
	hideme.css('display', 'none');
	$('input[name="item_meta[1788]"]').change(function () {
		var val1 = $(this).val();
		if (val1 == 'Option 1') {
			hideme.show();
		} else {
			hideme.hide();
		}
	});
});
</script>
 
  • Change #frm_radio_1831-1786-0 to the ID of the radio button option you want to show/hide.
  • Change 1788 to the ID of the radio button field you want to watch.
  • Change 'Option 1' to the value that will need to be chosen.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right