单选按钮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();


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM