checkbox

type="checkbox" name="checkstyle_code" value="${dic.CODE!}"
tag="${dic.NAME!}" style="margin-top: -4px; margin-left: 3px;">




$(function(){

$("[name='checkstyle_code']").change(function() {
       // alert("checked");
$("[name='checkstyle_code']").each(function() {
var chk_value = "";
var chk_code = "";
$('input[name="checkstyle_code"]:checked').each(function() {
chk_value += $(this).attr("tag") + ",";
chk_code += $(this).attr("value") + ",";
});
chk_value = chk_value.substring(0, chk_value.length - 1);
chk_code = chk_code.substring(0, chk_code.length - 1);
//$("#checkstyle_name").val(chk_code);
$("#checkstyle").val(chk_value);
});
    });

var strArray = [];
strArray = "${checkstyle!}".split(",");
//alert(strArray);
$("input[name='checkstyle_code']").each(function() {
for ( var i = 0; i <= strArray.length; i++) {
//  alert(strArray[i]);
//  alert($(this).attr("tag"));
if (strArray[i] == $(this).attr("tag")) {
$(this).iCheck("check");
}
}
}); 
}); 

你可能感兴趣的:(checkbox)