首页 > 解决方案 > 选中单选按钮时如何更新选择选项下拉列表

问题描述

我用于更新下拉列表的脚本。

$(document).ready(function() {
        $('input:radio').change(function(){
            var val = $('input:radio:checked').val();
            $('#Select1').val(0)
            $('.storeCategory, .storeList').hide();
            $('.' + val).show();
        });
    });

这里我使用尾选择。And it's not updating the 2nd select list when 2nd radio button is selected or checked

<select name="selectstorename" id="Select1" name="Select1" multiple class="select-store-move" required="">
                            <?php if($storelist){
                                foreach ($storelist as $key => $storecat) {
                            
                                    echo '<option  class="storeList" value="'.$storecat->store_id.'">'.$storecat->store_name.'</option>';                                 
                                }
                            } ?>
                            <?php if($catStore){
                                foreach ($catStore as $key => $catstore) {
                            
                                    echo '<option  class="storeCategory" value="'.$catstore->cat_id.'">'.$catstore->cat_name.'</option>';                                 
                                }
                            } ?>
                        </select>

两个单选按钮

<div class="radio-border storeCategoryRadioSelection">
                        <input type="radio" name="activateCoupon" type="radio" id="myRadio1" value="storeCategory">
                        <label for="myRadio1"> Store Category Wise</label>
                        <div id="user-selection-paragraph">
                            <span class="text-small">
                                radio description.
                            </span>
                        </div>  
                    </div>
                    <div class="radio-border storeWiseRadioSelection">
                        <input type="radio" name="activateCoupon" type="radio" id="myRadio2" value="storeList">
                        <label for="myRadio2"> Store Wise</label>
                        <div id="user-selection-paragraph">
                            <span class="text-small">
                                radio description.
                            </span>
                        </div>
                    </div>

标签: javascriptphp

解决方案


推荐阅读