/**
 * 
 */

$(document).ready(function getcategory_name() {
	$.ajax({
		type : "post",
		dataType : "json",
		url : basepath+"/admin/adminCategorySecond.action",
		data : {},
		success : function(data) {
			var itemtotal = "";
			$.each(data, function(i, item) {
				var cname = item.cname;
				item1 = "<option value='" + item + "'>" + item + "</option>";
				itemtotal = itemtotal + item1;
			});
			$("#cname").append(itemtotal);
		},
		error : function(e) {
		}
	});
}); 

function getselectBycategory_name() {
	var category_name = $("#category_name").val();
	$("#table  tr:not(:first)").empty("");
	$.ajax({
		type : "post",
		dataType : "json",
		url : basepath+"/Goods/selectBycategory_name",
		data : {
			category_name : category_name
		},
		success : function(data) {
			var itemtotal = "";
			$.each(data, function(i, item) {
				var id = item.id;
				var category_name = item.category_name;
				var btn="<input class='btn btn-primary btn-sm' type='button' id='Edit_btn' value='编辑' />";
				item1 = "<tr><td>" + id + "</td><td>" + category_name + "</td><td>"+btn +
						"<input type='button' value='删除' οnclick='dele()' />"+ "</td></tr>"; 
				itemtotal = itemtotal + item1;
			});
			$("#table").append(itemtotal);
			alert("查询成功");
		},
		error : function(e) {
			alert("查询失败");
		}
	});
}