Jump to content

checkbox check/uncheck problem


anton578

Recommended Posts

hI can anyone help me with my problem

im new to this....

 

heres my code...

foreach($contacts as $contact_id => $contact_data){
	if (! $contact_data["company_name"])
		$contact_company = $contact_data['contact_company'];
	else
		$contact_company = $contact_data['company_name'];
	if($contact_company  && $contact_company != $actual_company){
	$compId= $contact_data['contact_company'];
	echo "<h4><input type='checkbox' name='comp[]' value='$compId' onClick='check(this.value)' />$contact_company</h4>";			
	$actual_company = $contact_company;
	}
	$contact_department = $contact_data["dept_name"] ? $contact_data["dept_name"] : $contact_data["contact_department"];
	if($contact_department && $contact_department != $actual_department){
	$deptId =  $contact_data["contact_department"];
		echo "<h5><input type='checkbox' name='dept[]' value='$deptId' onClick='check2(this.value)' />$contact_department</h5>";
		$actual_department = $contact_department;
	}
	echo "  &nbsp<input type='checkbox' name='contact_id[]' value='$contact_id' />"; //list all contacts
	echo $contact_data["contact_first_name"]." ".$contact_data["contact_last_name"];
	echo "<br />";
}

 

 

 

 

Aim:  that code display all the contact list with checkbox... and they are sorted in their different companies and department....

       suppose to be when a company/department is checked it will check all the contact list under that department or company...

 

 

Problem:  The code that has a comment list all contacts is the code that will list all the contact list. so if i execute my javascript function "check()" when clicked all of the contact list will be checked because the variable name of all the contacts in my list are named the same. so is it possible to make a script that will check/uncheck contact list that is under its category. with my code above? im having difficulty because the variable name are the same. so when i clicked a category to go to my js function it will just check or uncheck all the contacts. disregarding its category coz i dont know how. can anyone help me to create a js function that fits with my problem?  ???

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.