导读:jquery如何提交checkbox的值?思路很简单,就是把选中的值都取出来,通过循环处理成字符串,然后传递出去。复制代码代码如下:
jquery如何提交checkbox的值?思路很简单,就是把选中的值都取出来,通过循环处理成字符串,然后传递出去。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jquery如何提交checkbox的值</title>
<script type="text/javascript" src="http://www.phpernote.com/js/jquery.min.js";></script>
<script type="text/javascript">
function submitForm(){
var str='';
$("#phpernote>[type=checkbox]").each(function(){
if($(this)[0].checked) {
str+=$(this).val()+',';
}
});
alert(str);
}
</script>
</head>
<body>
<form id="phpernote" action="javascript:submitForm();" method="post">
<input type="checkbox" value="1" />1<br />
<input type="checkbox" value="2" />2<br />
<input type="checkbox" value="3" />3<br />
<input type="checkbox" value="4" />4<br />
<input type="checkbox" value="5" />5<br />
<input type="submit" value="提交" />
</form>
</body>
</html>