javascript - 选中单选按钮时如何更新选择选项下拉列表
问题描述
我用于更新下拉列表的脚本。
$(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>
解决方案
推荐阅读
- java - 无法从 springboot 应用程序中具有“main”方法的类中的属性文件中读取属性以进行本地测试?
- machine-learning - 矩阵分解和线性回归的混合推荐系统
- input - 设置基本玩家移动 (UE4) 的最佳方式是什么?
- python - 如何使用python在pyqt5中自动启用水平和垂直滚动条
- javascript - Chrome Ajax 调用错误:ERR_BLOCKED_BY_CLIENT
- algorithm - 如何构造一个有效的算法来查找距顶点集 S 最远的顶点?
- python - 无法将任何软件包安装到 PyCharm 并给出错误“找不到满足要求的版本”
- html - 根据用户在文本框中的输入,使用条件来定义用户出生的年代
- ios - TestFlight 删除了我的新应用程序构建
- javascript - 如何在不同域 iframe 和 Angular 等父级之间进行通信?