现在的位置: 首页 > 综合 > 正文

更具后台返回值判断多选框、单选框是否选中

2018年05月05日 ⁄ 综合 ⁄ 共 2009字 ⁄ 字号 评论关闭

js代码:

<script type="text/javascript">
  $(function(){
    var a = "${ps.passagetype}";//运营商
     $("input[name='passagetype']").get(a-1).checked= true;
    var a = "${ps.pasIsSpPerfix}";//sp字冠支持 
     $("input[name='pasIsSpPerfix']").get(a-1).checked= true;
    if("${ps.pasIsSpExpend}"=='1'){
     $("#pasIsSpExpend").attr("checked",true);
    }if("${ps.pasIsSpLm}"=='1'){
     $("#pasIsSpLm").attr("checked",true);
    }if("${ps.pasStatus}"=='1'){
     $("#pasStatus").attr("checked",true);
    }if("${ps.pasIsDiy}"=='1'){
     $("#pasIsDiy").attr("checked",true);
    }if("${ps.pasIsLocalPro}"=='1'){
     $("#pasIsLocalPro").attr("checked",true);
    }if("${ps.pasCheck}"=='1'){
     $("#pasCheck").attr("checked",true);
    }if("${ps.pasIsSpPerfix}"=='1'){
     $("#pasIsSpPerfix").attr("checked",true);
    }if("${ps.pasIsConsum}"=='1'){
     $("#pasIsConsum").attr("checked",true);
    }
  });
 </script>

jsp代码:

<div class="subbg">
    <input type="radio" name="passagetype" id="passagetype" checked="checked" value="1"/><label>本省移动</label>
    <input type="radio" name="passagetype" id="passagetype" value="2"/><label>本省联通</label>
    <input type="radio" name="passagetype" id="passagetype" value="3"/><label>本省电信</label>
    <input type="radio" name="passagetype" id="passagetype" value="4"/><label>全国移动</label>
    <input type="radio" name="passagetype" id="passagetype" value="5"/><label>全国联通</label>
    <input type="radio" name="passagetype" id="passagetype" value="6"/><label>全国电信</label>
    <input type="radio" name="passagetype" id="passagetype" value="7"/><label>全能通道</label>
    </div>

<div class="subbg">
    扩展支持<input type="checkbox" name="pasIsSpExpend" id="pasIsSpExpend" value="true"/>
    超长短信<input type="checkbox" name="pasIsSpLm"  id="pasIsSpLm" value="true"/>
    状态报告<input type="checkbox" name="pasStatus"  id="pasStatus" value="true"/>
    独享通道<input type="checkbox" name="pasIsDiy"  id="pasIsDiy" value="true"/>
    支持回复<input type="checkbox" name="pasIsLocalPro" id="pasIsLocalPro" value="true"/>
    审核<input type="checkbox" name="pasCheck" id="pasCheck" value="true"/>
    </div>

抱歉!评论已关闭.