企业新闻

行业新闻 企业新闻

JS+JSP checkBox 全选具体实现

发布日期:2023-01-29 17:26 浏览次数:

复制代码 代码如下:

<script> 
function func(){ 
var options=document.getElementsByName("chkBox"); 
for (var i=0;i<options.length;i++){ 
if(!options[i].disabled){ 
options[i].checked=true; 



</script> 
<input type=checkbox name=chkBox value=1 disabled> 
<input type=checkbox name=chkBox value=1> 
<input type=checkbox name=chkBox value=1> 
<input type=checkbox name=chkBox value=1> 
<input type=button value="测 试" onclick="func()">

用javascript吧。 


复制代码 代码如下:

<html> 
<body> 
<script> 
function kk(){ 
var handleEl = document.getElementById("kkHandler"); 
var els = document.getElementsByName("kk"); 
for(i=0;i<els.length;i++){ 
els[i].checked = handleEl.checked; 
}


</script> 
<input type=checkbox onclick="kk()" name="kkHandler">全选<br> 
<input type=checkbox name="kk"> 
<input type=checkbox name="kk"> 
</body> 
</html>

2: 


复制代码 代码如下:

<form name="form" ID="Form1"> 
<input type="checkbox" name="id" value="" ID="Checkbox1">1 
<input type="checkbox" name="id" value="" ID="Checkbox2">2 
<input type="checkbox" name="chose" value="" onclick="selectAll()" ID="Checkbox5">allselect 
</form> 
<script> 
function selectAll() 

if(!document.form.id.length){ 
if(document.form.chose.checked){ 
document.form.id.checked=true; 

else{ 
document.form.id.checked=false; 


else{ 
for(var i=0;i<document.form.id.length;i++){ 
if(document.form.chose.checked){ 
document.form.id[i].checked=true; 

else{ 
document.form.id[i].checked=false; 




</script>

3: 


复制代码 代码如下:

<input type='checkbox' name='info' value='a'> 
<input type='checkbox' name='info' value='b'> 
<input type='checkbox' name='info' value='c'> 
<input type='checkbox' name='info' value='d'> 
<input type='checkbox' name='info' value='e'><br> 
<input type='button' value =' 全选 'onclick='check_all();'> 
<script> 
function check_all(){ 
arr = document.getElementsByName('info'); 
for(i=0;i<arr.length;i++){ 
arr[i].checked = true; 


</script>

X

截屏,微信识别二维码

微信号:

(点击微信号复制,添加好友)

  打开微信

微信号已复制,请打开微信添加咨询详情!