http://union.suning.com/aas/open/vistorAd.action?userId=124924&webSiteId=12164&adInfoId=6494&adBookId=48681&subUserEx=155412&vistURL=http://www.suning.com

jquery 二级联动

<tr>
<td class="tdwidth">城市:</td>
<td><select id="province" name="" style="width:175px;height:26px;" onchange="fuc()" >

</select> &nbsp;
<select id="city" name="" style="width:175px;height:26px;"> 
</select> </td>

</tr>

<script type="text/javascript">
$(document).ready(function () {
htmlobj = $.ajax({ url: "../img/json.js", async: false });
$.each(jQuery.parseJSON(htmlobj.responseText), function (index, content) { 
$("#province").append($("<option value=\"" + content.name + "\">" + content.name + "</option>")); 
});
$("#city").append($("<option value=\"1\">请选择</option>"));
});
function fuc() {
htmlobj = $.ajax({ url: "../img/json.js", async: false });
$("#city").html("");
$.each(jQuery.parseJSON(htmlobj.responseText), function (index, content) {
if (content.name == $("#province").val()) {
$.each(content.sub, function (i, contex) {
$("#city").append($("<option value=\"" + contex.name + "\">" + contex.name + "</option>"));
});
}
});
} 
</script>

 

posted @ 2017-04-09 17:23  .netpjava  阅读(153)  评论(0编辑  收藏  举报