»
EnglishFrenchVietnamese

Print - Check by Group - JavaScriptBank.com

Full version: jsB@nk » Form » Checkbox » Check by Group
URL: http://www.javascriptbank.com/check-by-group.html

Check by Group © JavaScriptBank.comBy utilizing a dropdown box, a user can check groups or subgroups of checkboxes.

Full version: jsB@nk » Form » Checkbox » Check by Group
URL: http://www.javascriptbank.com/check-by-group.html



JavaScript
<SCRIPT LANGUAGE="JavaScript">// Mike Elkins (m_c_elkins@hotmail.com)<!-- Begin  function selectivecheck(field, myselection)    {      var fieldid;      var pos;      var criteria;      var strng;      strng = myselection.value;      for (i=0; i<field.length; i++)        {          if (strng=="all")            {            field[i].checked = true;            }          else            {              fieldid = field[i].id;              pos = strng.substring(0,1);              criteria = strng.substring(1,2);  //this gets the information we want to evaluate              if (fieldid.substring(pos,pos+1)==criteria)                {                  field[i].checked = true;                }              else                {                  field[i].checked = false; //you could leave this out if you don't want to clear the check boxes                }            }        }    }//  End --></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form><table align="center"><tr><td><!--Load each ID with a string that will be parsed later -->  <input id=a1 type=checkbox name=list value="1">Group A SubGroup 1<br>  <input id=a2 type=checkbox name=list value="2">Group A SubGroup 2<br>  <input id=b1 type=checkbox name=list value="3">Group B SubGroup 1<br>  <input id=b2 type=checkbox name=list value="4">Group B SubGroup 2<br>  <input id=c1 type=checkbox name=list value="5">Group C SubGroup 1<br>  <input id=c2 type=checkbox name=list value="6">Group C SubGroup 2<br><!--Set your option values that contain a position and then the criteria--><p>Group Selection: <select size="1" name="mycombobox">  <option value="all">All Groups</option>  <option value="0a ">Group A</option>  <option value="0b ">Group B</option>  <option value="0c ">Group C</option>  <option value="11 ">SubGroup 1</option>  <option value="12 ">SubGroup 2</option></select><br><div align="center"><input type="button" value="Select Group" onclick=" selectivecheck(this.form.list, this.form.mycombobox)"></div></td></tr></table></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->