`
拖拖鞋
  • 浏览: 90591 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

级联下拉列表的实现

阅读更多
原创!转载请注明地址 http://ycde2009.iteye.com/blog/1990738
    在前端的组件上绑定事件,在该事件中使用ajax来异步请求,将返回结果组装成前台html代码。
//修改页面时下拉框的连动
//品牌修改时 连动车型

$("#brandID").change(changeBrand_Update);
function changeBrand_Update(){
	var value =$("#brandID").val();
	$("#vehicleModelID").html("");
	if(!value || "0"==value)
	{
		return;
	}
	$.ajax({
		  url: "${pageContext.request.contextPath}/brandJson?brandID="+value,
		  dataType: "json",
		  success:function(formData){
			  var html = "";
			  $.each(formData.entity,function(i,n){
				  if(n.entityID == $("#vehicleModelID_hidden").val())
				  {
					  html = html + "<option selected value="+n.entityID+">"+n.name+"</option>"
				  }
				  else
				  {
					  html = html + "<option value="+n.entityID+">"+n.name+"</option>"
				  }
			  });
			  $("#vehicleModelID").html(html);
		  }
	});
};

				  else
				  {
					  html = html + "<option value="+n.entityID+">"+n.name+"</option>"
				  }
			  });
			  $("#vehicleModelID").html(html);
		  }
	});
};
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics