Last active
April 21, 2022 14:01
-
-
Save jadealombro/455210743f81c6e6a7605d2b1e9a81c7 to your computer and use it in GitHub Desktop.
Disable some checkboxes, radio buttons, and dropdown options in WPForms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wpforms_wp_footer_end', function () { | |
?> | |
<script type="text/javascript"> | |
jQuery(function($){ | |
// This array contains all the options that will be disabled | |
// 2217 is the form ID | |
// 1, 2, 3 after #wpforms-2217-field_ are the field IDs | |
var disable = [ | |
'#wpforms-2217-field_1-container option[value="Second Choice"]', // Disable Second Choice option in a dropdown | |
'#wpforms-2217-field_2-container input[value="Second Choice"]', // Disable Second Choice option in a checkbox | |
'#wpforms-2217-field_2-container input[value="Third Choice"]', // Disable Third Choice option in a checkbox | |
'#wpforms-2217-field_3-container input[value="Third Choice"]' // Disable Second Choice option in a radio button (multiple choice) | |
]; | |
$.each( disable, function( key, value ) { | |
$(value).prop('disabled', true); | |
}); | |
}); | |
</script> | |
<?php | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment