JS全选CheckBox

//type=1 全选
//type=2 全不选
//type=3 反选
function selectAll(form, type) 
{
	var elems = form.elements;
	for ( var i = 0 ; i < elems.length ; i++ ) 
	{
		var e = elems[i];
		if(e.type == 'checkbox')
		{
			switch(iType)
			{
			case 1:
				e.checked = true;
				break;
			case 2:
				e.checked = false;
				break;
			case 3:
				e.checked = !(e.checked);
				break;
			}
		}
	}
}

function   checkAll()
{
	var elems=document.getElementsByTagName( "INPUT ");
	for(i=0;i<elems.length;i++)
	{
		var e = elems[i];
		if(e.type.toLowerCase()== "checkbox ")e.checked=true;
	}    
} 

Leave a Reply

Your email address will not be published. Required fields are marked *

*