select下拉框内容回显 并将对应的option设置为selected选中状态
来源:互联网 发布:香港银行开户 知乎 编辑:程序博客网 时间:2024/05/21 06:48
<script type="text/javascript"> var productId = '${product.productId}'; _findSelectedData(); function _findSelectedData(){ jQuery.ajax({ dataType: "json", url: "/product/getProductById", data: {productId:productId}, type: "POST", success: function (result) { if (result.code == 1) { var data = result.data; var productType = data.productType;//经验大类 var isAProduct = data.isAProduct;//是否短期活动 //方法1 $('#productType').find('option[value='+productType+']').atrr('selected','selected'); $('#isAProduct').find('option[value='+isAProduct+']').atrr('selected','selected'); //方法2 var optionsLength = document.getElementById('productType').options.length; var pt = document.getElementById('productType'); for(var i = 0; i < optionsLength; i++){ var option = parseInt(document.getElementById('productType').options[i].value); if(option == productType){ pt.options[i].setAttribute("selected","true"); } } var aLength = document.getElementById('isAProduct').options.length; var ap = document.getElementById('isAProduct'); for(var j = 0; j < aLength; j++){ var optionA = parseInt(document.getElementById('isAProduct').options[j].value); if(optionA == isAProduct){ ap.options[j].setAttribute("selected","true"); } } } } }); }
阅读全文
0 0
- select下拉框内容回显 并将对应的option设置为selected选中状态
- 动态给option设置selected后,select下拉框显示不正确,selected=“selected”的option
- 删除和添加select下拉框选中的内容option,以及清空option选项
- select动态添加option与动态设置下拉框默认选项(selected)的问题(原创)
- jQuery操作select(设置某个option为选中状态)
- 利用js弹出select下拉选中option的内容
- select标签 selected 选中状态动态设置
- 【js:片断】jQuery 设置 select 下拉框的选中状态
- 把<select>中option的转换为数组,并根据option text的值,设置选中,并刷新
- jQuery设置下拉框select 默认选中第一个option
- jQuery设置下拉框select 默认选中option
- jQuery设置下拉框select 默认选中第一个option
- 快速取得select选中的selected option的值
- jquery select option 选中下拉框的text文本
- jquery 获取select下拉框 选中的option ???
- 下拉框默认选中select的第一个option
- HTML下拉框<select>默认选中<option>
- 重置select select2下拉框为选中状态
- JavaEE学习08--jsp
- lightgbm python基本使用 --mac下操作
- sql之left join、right join、inner join的区别
- 云计算非功能性-可靠性可用性优化指标
- PAT 甲级 1016. Phone Bills
- select下拉框内容回显 并将对应的option设置为selected选中状态
- 使用MongoDB类操作MongoDB数据库总结
- (VS2010)MFC中List Control基本用法
- OnCtlColor函数的用法
- angular 4 表单
- 原生js实现对select下拉列表的内容过滤
- 圆圈中最后剩下的数
- 基本VLAN特性配置与管理——5
- Shader-数据类型