Created
September 2, 2019 07:20
-
-
Save ayonliu/f1c3508e44863dbe4e2d001d307f0e8a to your computer and use it in GitHub Desktop.
Check all checkbox by name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function opcheckboxed(objName, type){ | |
var objNameList=document.getElementsByName(objName); | |
if(null!=objNameList){ | |
for(var i=0;i<objNameList.length;i++){ | |
if(objNameList[i].checked==true) | |
{ | |
if(type != 'checkall') { // 非全选 | |
objNameList[i].checked=false; | |
} | |
} else { | |
if(type != 'uncheckall') { // 非取消全选 | |
objNameList[i].checked=true; | |
} | |
} | |
} | |
} | |
} | |
// example | |
opcheckboxed('oid[]', 'checkall'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment