码迷,mamicode.com
首页 > Web开发 > 详细

单选按钮radio和下拉选择select,ajax返回数据回显对应值

时间:2018-07-23 12:42:11      阅读:663      评论:0      收藏:0      [点我收藏+]

标签:cte   checked   bsp   gil   option   value   下拉   tty   select   

html页面:

<div class="fileradio">
  <h5>性 别:</h5>
  <input type="radio" name="sex" id="boy" value="0"><p>男</p>
  <input type="radio" name="sex" id="gil" value="1"><p>女</p>
</div>

<div class="fileannpas">
  <h5>证件类型:</h5>
  <select class="phonttype" name="phonttype" id="patientCardType">
  
  </select>
</div>

 

js:

ajax传id返回该条id的数据

if(data.data.PATIENT_SEX==0){
  $("#boy").attr(‘checked‘, ‘checked‘);
}else{
  $("#gil").attr(‘checked‘, ‘checked‘);
}

$("#patientCardType selected:").val(data.data.CARD_TYPE);

 

获取radio值:

var sex=$("input[type=‘radio‘]:checked").val();

 

获取select的value值:

var cardType=$("#patientCardType").val();

 

获取select的html值:

var cardName=$("#patientCardType option:selected").html();

单选按钮radio和下拉选择select,ajax返回数据回显对应值

标签:cte   checked   bsp   gil   option   value   下拉   tty   select   

原文地址:https://www.cnblogs.com/fanting/p/9353756.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!