首页 > 代码库 > 全选反选取消-js代码

全选反选取消-js代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script type="text/javascript">function selectAll(){    var inputs=document.checkForm.interesting;    //for(var i in inputs){        for(var i=0;i<inputs.length;i++){        inputs[i].checked=true;    }}function deselectAll(){    var inputs=document.checkForm.interesting;    for(var i in inputs){        inputs[i].checked=false;    }}function reverseAll(){    var inputs=document.checkForm.interesting;    for(var i in inputs){        inputs[i].checked=!inputs[i].checked;        }}</script></head><body><form name="checkForm" action="#" method="get">兴趣爱好:<br /><input type="checkbox" name="interesting" value="1" />足球<br /><input type="checkbox" name="interesting" value="2" />篮球<br /><input type="checkbox" name="interesting" value="3" />羽毛球<br /><input type="checkbox" name="interesting" value="4" />台球<br /><input type="checkbox" name="interesting" value="5" />乒乓球<br /><input type="checkbox" name="interesting" value="6" />橄榄球<br /></form><input type="button" value="全选" onclick="selectAll()" /><input type="button" value="反选" onclick="reverseAll()" /><input type="button" value="取消" onclick="deselectAll()" /></body></html>