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

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();

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