1
//thinkphp和javascript对复选框的处理
2
//模板输出
3 <volist id="vo" name="list">
4
//填充盒子
5 <div>
6 <input type="checkbox" value="{
$vo.name}"name="box[]">
{$vo.
name}
7 </div>
8
//一排三个满了以后换行
9 <
if condition="
$i%3==0">
10 <br/>
11 </
if>
13 </volist>
14
//js验证代码
15
function checkbox()
16
{
17
18
//得到元素
19
var boxs=document.getElementsByName("box[]"
);
20
//得到长度
21
var boxlength=boxs.
length;
22
var boxvalue=''
;
23
for(
var i=0;i<boxlength;i++
)
24
{
25
if(boxs[i].
checked)
26
{
27 boxvalue+=boxs[i].value+','
;
28
29
}
30
if(boxvalue==''
)
31
{
32
return false;
33
34
}
35
else{
36
return true;
37
38
}
39
40
}
41
42
}
43
//thinkphp端接受语句
44
$boxs=I('post.box'
);
45
for(
$i=0;
$i<
count(
$boxs);
$i++
)
46
{
47
echo $boxs[
$i];
48 }
转载于:https://www.cnblogs.com/zjl10101314/p/9456820.html