js checkbox全选功能 精简版

 

<form name="emosCoreForm" method="post"
			action="<%=request.getContextPath()%>/toEmosOrderCheck.do">
......
<table width="100%" border="0" cellspacing="1" cellpadding="0"
								align="center" class="form-tb">
								<tr>
									<th
										style="background-image: url(<%=request.getContextPath()%>/ Images/ title . gif ); font-size: 9pt; width: 5%">
										全选
										<input id="selectAll" type="checkbox" name="selectAll"
											value="selected" onClick="checkAll()" />
									</th>
......

 

 

 

function checkAll(){
   			for(var i=0;i<emosCoreForm.elements.length;i++){
		   		if(emosCoreForm.elements[i].type=="checkbox"&&emosCoreForm.elements[i].name!="selectAll"){
		   		emosCoreForm.elements[i].checked =!emosCoreForm.elements[i].checked; 
		   		}
   			}

   		}

你可能感兴趣的:(checkbox)