<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>checkbox</title>
<script src="js/jquery-1.4.4.min.js" type="text/javascript"></script>
</head>
<body>
<input name="km" type="checkbox" value="sx"/>数学
<input name="km" type="checkbox" value="yw" />语文
<input name="km" type="checkbox" value="yy" />英语
<div id="div1"></div>
<script type="text/javascript">
$("input[name='km']").click(function(e){//当name='km'的复选框被点击时
var str = "";
$("input[name='km']").each(function(){//遍历所有name=‘km’的复选框
var v = $(this).attr("checked");
if(v){
str += $(this).attr("value") +",";//累加已选值,逗号间隔
}
})
if(str!=""){
str = str.substr(0, str.length);
$("input[name='km']").click(function(e){
$.ajax({
type : "POST",
url : "",//action 地址
data : {
param1: '',
param2: ''//参数列表
},
success : function(msg) {
// 回调函数
$("#div1").html(msg);
}
});
});
}
alert(str)
});
</script>
</body>
</html>