HTML代码是:
入库类型是: <select id="selectIn" onchange="goUrl(this.options[this.selectedIndex])"> <!--<option value="0">请选择</option>--> <!--<option value="comAdmin_in_purchase.html">采购</option>--> <!--<option value="comAdmin_in_return.html">归还</option>--> <!--<option value="comAdmin_in_gain.html">受赠</option>--> </select> JavaScript: //选择触发事件 function goUrl(obj){ if(obj.value==1){ window.location.href="comAdmin_in_purchase.html"; } if(obj.value==2){ window.location.href="comAdmin_in_return.html"; } if(obj.value==3){ window.location.href="comAdmin_in_gain.html";
} }
JavaScript代码是:
$(document).ready(function () { getIntype(); }); function getIntype(){ $.ajax({ type:"post", dataType:"json", url:"http://192.168.35.111:8080/officeSystem/InstorageCheckIn/getInstorageType.do", success:function(data){ var len=data.length; $("#selectIn").append(('<option value="0"> </option>')); for(var i=0;i<len;i++){ $("#selectIn").append(('<option value='+data[i].id+'>'+data[i].name+'</option>')); } }, error:function(data){ console.log(data); } }); }
结果截图: