jquery怎么根据后台传过来的值动态设置下拉框、单选框选中
2017-06-24 19:20
736 查看
$(function(){ varsex=$("#sex").val(); varmarriageStatus=$("#marriageStatus").val(); vareducation=$("#education").val(); if(!isnull(sex)){ $("input:radio[name='sex'][value="+sex+"]").attr('checked','true'); } if(!isnull(marriageStatus)){ $("input:radio[name='marriageStatus'][value="+marriageStatus+"]").attr('checked','true'); } if(!isnull(education)){ $("#education1option[value='"+education+"']").attr("selected",true); } });
<inputtype="hidden"id="sex"value="${serviceInfo.sex}"/> <inputtype="radio"name="sex"value="0"checked="checked"/>男 <inputtype="radio"name="sex"value="1"/>女
<inputtype="hidden"id="marriageStatus"value="${serviceInfo.marriageStatus}"/> <inputtype="radio"name="marriageStatus"value="0"checked="checked"/>是 <inputtype="radio"name="marriageStatus"value="1"/>否
<inputtype="hidden"id="education"value="${serviceInfo.education}"/> <selectname="education"id="education1"> <optionvalue="硕士">硕士</option> <optionvalue="本科">本科</option> <optionvalue="大专">大专</option> <optionvalue="其它">其它</option> </select>
详细介绍请查看全文:
原文博客的链接地址:
相关文章推荐
- jquery怎么根据后台传过来的值动态设置下拉框、单选框选中
- jquery 根据后台传过来的值动态设置下拉框、单选框选中
- layui动态设置下拉框数据,根据后台数据设置选中
- Jquery 根据value值设置下拉列表(select)默认选中项
- Jquery根据后台数居设置select。radio,checkbox选中
- jQuery怎么根据某个特定的值动态让select下的option选中
- jquery根据特定的值设置 input type=radio 单选框为选中状态
- jquery根据后台返回值设置checkbox选中
- jquery easy ui中根据第一个下拉框框选中的值,设置第二个下拉框是否可以编辑
- jQuery怎么根据某个特定的值动态让select下的option选中
- Jquery单选框、复选框、下拉框动态设置默认项,及动态获取选中项。
- Jquery 根据value值设置下拉列表(select)默认选中项
- jQuery怎么根据某个特定的值动态让select下的option选中
- 【zTree】zTree根据后台数据生成树并动态设置前面的节点复选框的选中状态
- jQuery Easy UI中根据第一个下拉框选中的值设置第二个下拉框是否可以编辑
- chosen.jquery 插件 动态设置下拉选项被选中selected
- 通过jquery来实现文本框和下拉框动态添加效果,能根据自己的需求来自定义最多允许添加数量,实用的jquery动态添加文本框特效
- jQuery选中多选框和单选框和下拉框
- Jquery 通过 文本 text设置 select 下拉框 的 选中项 (非通过 value)
- 一般操作需要导入的jquery包(jquery.js包)和 jquery操作select下拉列表(取值及设置选中某一个option)