function chkall(input1,input2)
{
    var objForm = document.forms[input1];
    var objLen = objForm.length;
    for (var iCount = 0; iCount < objLen; iCount++)
    {
        if (input2.checked == true)
        {
            if (objForm.elements[iCount].type == "checkbox")
            {
                objForm.elements[iCount].checked = true;
            }
        }
        else
        {
            if (objForm.elements[iCount].type == "checkbox")
            {
                objForm.elements[iCount].checked = false;
            }
        }
    
    }
}

//aspx页面调用

chkall('Form1',this)   //Form1是form的名称
<input type='checkbox' name='c1'  onclick="chkall('Form1',this)">选择所有
posted on 2007-04-12 14:30  汤智程  阅读(678)  评论(0)    收藏  举报