...

View Full Version : See if you can help me with this problem



webDevWarrior
03-11-2009, 03:39 PM
Hi all. I'm stuck and need some help with javascript.

I have a tree view where 170 items are divided in 53 categories. Some of these items appear in more than one category. I need to be able to select all the same items in different categories when a user selects one item in case it's repeated. Here's an example

------------------
Administration/Management/HR
Administration and Leadership Issues
Consulting
Cultural Diversity
Health Services Administration
Nursing Home Administration

Long Term Care
Geriatrics
Home Health Care
Nursing Home Administration
Long Term care
-------------------

As you can see Nursing Home Administration shows up on both categories. All items come with a checkbox. What I need is to when a user checks Nursing Home Administration (for instance) all Nursing Home Administration gets checked wherever they appear. Basically one click checks all alike items.

Thank you for any help.

freedom_razor
03-11-2009, 10:16 PM
You have to post your code or better a link to your site.

ninnypants
03-12-2009, 02:21 AM
this code will let you get the elements by a class name, so all you'll have to do is give them a distinct class name for that group


document.prototype.getElementsByClass = function(theClass){
els = document.getElementsByTagName("*");
elements = new Array();
pattern = new RegExp('(^| )'+theClass+'( |$)')
for(i = 0; i < els.length; i++){
cls = els[i].className;
if(pattern.test(cls)){
elements.push(els[i]);
}
}
return elements;
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum