I am working on a PHP project. After adding class chosen-select
for the <select>
field. The disable function does not working. If it is without the chosen-select
class, it performed disabled function very well but there is no CSS style for the field anymore. Is there any expert who is willing to give some valuable comment to me?
Here is my code:
<div class="col-lg-6 col-md-6 col-sm-5 col-xs-12">
<div class="field-holder">
<input type="text" placeholder="<?php _e( 'Restaurant Name', 'foodbakery' ) ?>" name="search_title" id="search_rest" onkeyup="disableDropDown()" value="<?php echo esc_html( $search_title ) ?>">
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-5 col-xs-12">
<div class="field-holder">
<div class="select-holder">
<select data-placeholder="" class="chosen-select" id="search_cusine" name="search_cusine" onchange="disableTextField()">
<?php
global $foodbakery_plugin_options;
$selected_fileds = isset( $foodbakery_plugin_options['default_cousins_list'] ) ? $foodbakery_plugin_options['default_cousins_list'] : '';
foreach ( $selected_fileds as $val ) {
$restaurant_type_cate = get_term_by( 'slug', $val, 'restaurant-category' );
echo '<option value='. esc_html( $restaurant_type_cate->name ) .'>' . esc_html( $restaurant_type_cate->name ) . '</option>';
}
?>
</select>
<script>
function disableDropDown() {
var x = document.getElementById("search_rest").value;
if (x != ''){
document.getElementById("search_cusine").disabled= true;
}
else{
document.getElementById("search_cusine").disabled = false;
}
}
</script>
</div>
</div>
</div>