anton578 Posted September 18, 2008 Share Posted September 18, 2008 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 "  <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? ??? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted September 18, 2008 Share Posted September 18, 2008 I haven't read your code, but you can use an associative array. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.