// 判断是否选中
function anyChecked(){
var elements=document.form1.elements; // form1为表单name的值
var counter=elements.length;
for(var i=0;i<counter;i++){
var element=elements[i];
alert();
if(element.checked == true){
alert(element.value);
return true;
}
}
return false;
}
//全选
function selectAll(){
var checklist = document.getElementsByName ("controlAll");
if(document.getElementById("selectAll").checked)
{
for(var i=0;i<checklist.length;i++)
{
checklist[i].checked = 1;
if(i == checklist.length-1){
id = id + checklist[i].value;
}else{
id = id + checklist[i].value + ',';
}
}
}else{
for(var j=0;j<checklist.length;j++)
{
checklist[j].checked = 0;
}
id = "";
}
}
//多选
var checklist = document.getElementsByName ("controlAll");
for(var i=0;i<checklist.length;i++){
if(checklist[i].checked == true && i == checklist.length-1){
id = id + checklist[i].value;
}else if(checklist[i].checked == true){
id = id + checklist[i].value + ',';
}
}
// html 代码
<tr class="biaoge_h">
<th><input type="checkbox" οnclick="selectAll()" name="selectAll" id="selectAll" value=""></input></th>
<th>省份</th>
<th>市份</th>
<th>操作</th>
</tr>
<tr>
<td><input type="checkbox" id="controlAll" name="controlAll" value="<%=provinceId %><%=cityId %>"></input></td>
<td align="center"><%=provinceName %></td>
<td align="center"><%=cityName%></td>
<td align="center">
<%= oper %>
</td>
</tr>