首页 > Web开发 > 详细

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

时间:2018-07-23 11:45:24      阅读:859      评论:0      收藏:0      [点我收藏+]

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返回数据回显对应值

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!