我正在研究一个PHP项目。在为chosen-select
字段添加类<select>
之后。禁用功能不起作用。如果没有chosen-select
类,则它会很好地执行禁用的功能,但该字段不再具有CSS样式。有没有愿意给我一些宝贵意见的专家?
这是我的代码:
<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>