I have the following code (it's jquery but uses php to add in the dynamic variables):
jQuery(document).ready(function($){
var arr = [ 'select', 'checkbox', 'radio' ];
var thisForm = 'select#widget-layers-widget-form_builder-<?php echo $this->number; ?>-form_builders-<?php echo esc_attr( $item_guid ); ?>-input_type';
if ($('select#widget-layers-widget-form_builder-<?php echo $this->number; ?>-form_builders-<?php echo esc_attr( $item_guid ); ?>-input_type option:selected').val() == 'select'){
$('#select-options-<?php echo esc_attr( $item_guid ); ?>').show();
}else{
$('#select-options-<?php echo esc_attr( $item_guid ); ?>').hide();
}
$(thisForm).change(function(){
if ($('select#widget-layers-widget-form_builder-<?php echo $this->number; ?>-form_builders-<?php echo esc_attr( $item_guid ); ?>-input_type option:selected').val() == 'select'){
$('#select-options-<?php echo esc_attr( $item_guid ); ?>').show();
}else{
$('#select-options-<?php echo esc_attr( $item_guid ); ?>').hide();
}
});
});
The purpose of this is to check the value of a dropdown menu and show/hide an element based on the selection. Currently, the code is designed to work if the dropdown selection == 'select', however, I want to add an array of results here, essentially, if the dropdown value is equal to 'select', 'checkbox' or 'radio'.
How can I achieve this by writing an array and checking the value against it?