if (typeof (vikecn_class) != undefined) {
$("#selcl1").html("<option value='0'>选择大类</option>");
$("#selcl2").html("<option value='0'>选择小类</option>");
var h_c1 = $("#h_c1").val();
var h_c2 = $("#h_c2").val();
$.each(vikecn_class, function (i, item) {
$("#selcl1").append("<option value='" + item.id + "' " + ((h_c1 == item.id) ? "selected" : "") + " >" + item.name + "</option>");
if (item.id == h_c1) {
$.each(item.children, function (i, subitem) {
$("#selcl2").append("<option value='" + subitem.id + "' " + ((h_c2 == subitem.id) ? "selected" : "") + ">" + subitem.name + "</option>");
});
}
});
$("#selcl1").change(function () {
var index = $('option:selected', '#selcl1').index();
$("#selcl2").html("<option value='0'>选择小类</option>");
if (index > 0) {
$.each(vikecn_class[index - 1].children, function (i, item) {
$("#selcl2").append("<option value='" + item.id + "'>" + item.name + "</option>");
});
}
});
$(".rowc1").each(function () {
var id = $(this).attr("data");
var subid = $(this).next().attr("data");
var rowc1 = $(this);
var rowc2 = $(this).next();
$.each(vikecn_class, function (i, item) {
if (item.id == id)
{
rowc1.html(item.name);
$.each(item.children, function (i, subitem) {
if (subitem.id == subid)
{
rowc2.html(subitem.name);
return false;
}
});
return false;
}
});
});
}