首页 > 代码库 > select下拉二级联动
select下拉二级联动
<li>号:<select id="ids" name="ids" onchange="opt()">
<c:forEach var="t" items="${terminal}">
<option value="http://www.mamicode.com/${t.terminalid}" selected>${t.displayname}</option>
</c:forEach>
</select></li>
<li>号:<select id="id" name="id">
<c:forEach var="b" items="${box}">
<option value="http://www.mamicode.com/${b.boxid}" selected>${b.dispalyname}</option>
</c:forEach>
</select></li>
function opt(){
var id = $("#ids").val();
$.ajax({
type: "POST",
url: "${basePath}/cardInfo/selectByid?id="+id,
success: function(msg){
var myobj=(eval("(" + msg + ")").msg);
$("#id").html("");
$.each(myobj,function(i,val){
$("#id").append("<option value="http://www.mamicode.com/+val.id+">"+val.name+"</option>");
})
}
});
}
select下拉二级联动