Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check checkboxes in a group.

Status
Not open for further replies.

garry1

Programmer
Dec 6, 2002
49
US
I have a query which gets the following values - company names and emp names. I display the results grouping on a company name.

<cfoutput query="emp" group="company_name">
<input type="checkbox" name="check" value="#company_name#">#company_name#
<cfoutput>
<input type="checkbox" name="checkbox" value="#employee_name#">#employee_name#
</cfoutput>
</cfoutput>

I have a select all button which checks all the checkboxes on a form.

My problem is if a group check box is checked how do I check the values in that group only.

For example if user checks company A checkbox than all the checkboxs of company A employees should be checked.

Thanks.
 
I asked a similar question a year or so ago, and here's a modified version of the answer I got...

Code:
<cfoutput query="emp" group="company_name"> 
   <cfset chknow="">
   <cfset chktime=randrange(1,10000)>
   <input type="checkbox" name="check"   value="#company_name#" oncheck="CA#chktime#()">#company_name#
  <cfoutput>
    <input type="checkbox" name="checkbox"   value="#employee_name#">#employee_name#
    <cfset chknow = listappend(chknow,employee_name)>
  </cfoutput>
  <script>
    <!--
      function CA#chkTime#(){
       for(i=0;i<document.myForm.atype.length;i++)
       {
        var myList = "#chknow#";
        var listArray = myList.split(",");

        for(j=0;j<listArray.length;j++){
         if(document.myForm.atype[i].value == listArray[j]){
          document.myForm.atype[i].checked = true;
          break;
         }
        }
       }
      }
    -->
  </script>
</cfoutput>

I got it from

You might hop over there and thank him for his help.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Thankyou webmigit.

The check part works. How do I uncheck the child checkboxes when the group checkbox is unchecked.

I am using the same checkbox for check and uncheck.

 
Take the script to the js forum forum216 and ask them how to mod it so that clicking the parent box while checked will uncheck all child boxes.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top