»
EnglishFrenchVietnamese

Print - Check/Uncheck All - JavaScriptBank.com

Full version: jsB@nk » Form » Checkbox » Check/Uncheck All
URL: https://www.javascriptbank.com/check-uncheck-all.html

Check/Uncheck All © JavaScriptBank.comDynamically checks and unchecks all the checkboxes in a form when a checkbox is clicked. Much easier than manually hard-coding the checkbox names, for sure.

Full version: jsB@nk » Form » Checkbox » Check/Uncheck All
URL: https://www.javascriptbank.com/check-uncheck-all.html



JavaScript
<SCRIPT language=javascript>var ie;if (document.all)ie = true;elseie = false;function _ca(obj)  {  var Count = 11; // number of checkboxes    for(var ii=1;ii<=Count;ii++)    {if (ie)  {  box = document.all["d"+ii];  box.checked = obj.checked;  }else  {  box = document.getElementsByName("d"+ii);  box[0].checked = obj.checked;  }}  }</SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<P><INPUT onclick="javascript: _ca(this);" type=checkbox value=checkbox name=checkbox> &nbsp;Check/UnCheck All</P><P><INPUT type=checkbox value=checkbox name=d1> Item 1<BR><INPUT type=checkbox value=checkbox name=d2> Item 2<BR><INPUT type=checkbox value=checkbox name=d3> Item 3<BR><INPUT type=checkbox value=checkbox name=d4> Item 4<BR><INPUT type=checkbox value=checkbox name=d5> Item 5<BR><INPUT type=checkbox value=checkbox name=d6> Item 6<BR><INPUT type=checkbox value=checkbox name=d7> Item 7<BR><INPUT type=checkbox value=checkbox name=d8> Item 8<BR><INPUT type=checkbox value=checkbox name=d9> Item 9<BR><INPUT type=checkbox value=checkbox name=d10> Item 10<BR><INPUT type=checkbox value=checkbox name=d11> Item 11<BR></P><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->