Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow See if you can help me with this problem

    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.

  • #2
    Regular Coder
    Join Date
    Dec 2008
    Location
    Tannhäuser Gate
    Posts
    286
    Thanks
    7
    Thanked 58 Times in 57 Posts
    You have to post your code or better a link to your site.

  • #3
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    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
    Code:
    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;
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •