Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7637739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:00:50+00:00 2026-05-31T08:00:50+00:00

javascript(jquery) $(‘.ic_parent’).change(function(){ var id = $(this).attr(‘value’) while (id.length >0){ if ($(this).attr(‘checked’)) { $(‘#update_ics_table’).find(‘input:checkbox[id =

  • 0

javascript(jquery)

$('.ic_parent').change(function(){
  var id = $(this).attr('value')
  while (id.length >0){
    if ($(this).attr('checked')) {
      $('#update_ics_table').find('input:checkbox[id = "child-of-' + id + '"]').attr('checked', $(this).attr('checked'));
    }else{
      $('#update_ics_table').find('input:checkbox[id = "child-of-' + id + '"]').removeAttr('checked');
    }
    id = $('#update_ics_table').find('input:checkbox[id = "child-of-' + id + '"]').attr('value')
  }
});

I have this treetable and would like to have cascade checkbox select.

When I click on the root its suppose to click all the children like so

root(selected)
  --child1(selected)
    -----subchild1(selected)
    -----subchild2(selected)
    -----subchild3(selected)
  --child2(selected)
    -----subchild1(selected)
    -----subchild2(selected)

My current code doesn’t check the subchild1 and 2 for the child2

How would I modify my code so that this is possible?

SOLVED:

Ok this hopefully helps people who came across this post hoping to implement such treetable. F. Calderan pointed out a good code but it was only doing half the job as if you click a parent instead of grandparent, nothing happens.

$('.blah).live('change',function(){
  var id = $(this).attr('value')
  var state = $(this).attr('checked')
  var plat = $(this).attr('platform')
  child_checker = $('#update_cycles_table').find('input:checkbox[key ^= "child-of-' + id + '_'+plat+'"]').attr('checked')
  if (child_checker == "checked"){
    $(this).removeAttr('checked')
  }
  while (id.length >0){
    if (state){
      $('#update_cycles_table').find('input:checkbox['+key+' ^= "child-of-' + id + '_'+plat+'"]').attr('checked', 'checked')    
    }else{
      $('#update_cycles_table').find('input:checkbox['+key+' ^= "child-of-' + id + '_'+plat+'"]').removeAttr('checked');
    }
  id=($('#update_cycles_table').find('input:checkbox['+key+' ^= "child-of-' + id + '_'+plat+'"]').attr('value'));
  }
});

you also need a childcheck to makesure that when you click middle of the tree, the top also gets unchecked. Without the checker it will not recognize that the checkbox was not check and will not perform anything.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:00:51+00:00Added an answer on May 31, 2026 at 8:00 am

    I would recommend not depending on IDs and the like to accomplish this behaviour. If you use HTML to properly describe the structure, it is easy to pick out the right elements in jQuery.

    I made a quick example at http://jsfiddle.net/jRAcq/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

JavaScript (jQuery) function display_youtube(new_url) { $('#movie_url').removeAttr('value'); $('#embed_url').removeAttr('src'); $(document).ready(function() { $('#movie_url').attr('value', new_url); $('#embed_url').attr('src', new_url); $('#shade').css('display',
I've got this JavaScript/jquery code: $(document).ready(function() { var audioElement = document.createElement('audio'); var secondtrack =
Given the following javascript (jquery) $(#username).keyup(function () { selected.username = $(#username).val(); var url =
JavaScript (JQuery) $('input').keyup(function(e) { var code = e.keyCode ? e.keyCode : e.which; switch(code) {
I have the following Javascript/jQuery function: function addEventHandler(){ $(div).mouseenter(function() { $(this).html(Over); }).mouseleave(function() { $(this).html(Out);
i have javascript jquery that looks like this: var userInput = prompt(Liquid Handler #:,
Javascript jQuery event handling If on event (for example 'click') bound one function for
New to javascript/jquery and having a hard time with using this or $(this) to
I have a javascript/jQuery block as a callback after $.get function: function myCallBack(data, textStatus)
I'm using JavaScript/Jquery to make a page auto-update with a value from a database,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.