dounaidu0204 2018-06-27 08:16
浏览 67

为什么为“select-option”字段添加一个类使“禁用”功能不起作用?

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>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)