Home > Web Front-end > JS Tutorial > JS method to implement statistics on the number of selected check boxes and prompt confirmation and cancellation_javascript skills

JS method to implement statistics on the number of selected check boxes and prompt confirmation and cancellation_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 15:51:50
Original
1113 people have browsed it

The example in this article describes how to implement JS to count the number of selected check boxes and prompt confirmation and cancellation. Share it with everyone for your reference. The specific implementation method is as follows:

The javascript part is as follows:

<script type="text/javascript"> 
function yesno() { 
  var inputs = document.getElementsByName("ck[]"); 
  var checked_counts = 0; 
  for(var i=0;i<inputs.length;i++){ 
    if(inputs[i].checked){checked_counts++; 
    } 
  } 
  if(confirm("你已选择了 " + checked_counts + " 个网址,\n你确定选择删除过滤网址吗&#63;")){ 
   //return true; 
   ShowDiv('MyDiv','fade'); 
  }else{ 
   return false; 
  } 
}  
</script>
Copy after login

The html page part is as follows:

<form id="form1" name="form1" method="post" action=""> 
<input type="checkbox" name="ck[]" id="ck[]" value="{$vo.id}" onclick="javascript:chkRow(this);"> 
<input type="checkbox" name="ck[]" id="ck[]" value="{$vo.id}" onclick="javascript:chkRow(this);"> 
<input type="checkbox" name="ck[]" id="ck[]" value="{$vo.id}" onclick="javascript:chkRow(this);"> 
<input type="checkbox" name="ck[]" id="ck[]" value="{$vo.id}" onclick="javascript:chkRow(this);"> 
<input type="checkbox" name="ck[]" id="ck[]" value="{$vo.id}" onclick="javascript:chkRow(this);"> 
<input type="checkbox" name="ck[]" id="ck[]" value="{$vo.id}" onclick="javascript:chkRow(this);"> 
<input type="checkbox" name="ck[]" id="ck[]" value="{$vo.id}" onclick="javascript:chkRow(this);"> 
<input type="checkbox" name="ck[]" id="ck[]" value="{$vo.id}" onclick="javascript:chkRow(this);"> 
<input type="checkbox" name="ck[]" id="ck[]" value="{$vo.id}" onclick="javascript:chkRow(this);"> 
<input type="checkbox" name="ck[]" id="ck[]" value="{$vo.id}" onclick="javascript:chkRow(this);"> 
<input type="submit" name="submit" id="submit" class="subbut" onclick="return yesno();" value="选择删除信息"> 
</form> 

Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Where is js written?
From 1970-01-01 08:00:00
0
0
0
js file code not found
From 1970-01-01 08:00:00
0
0
0
js addClass not working
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template