You are viewing limited content. For full access, please sign in.

Question

Question

If a Row Has a Column Checkmark Selected, Checkmark Each Row that Comes After It

asked on April 26, 2018

I have a table that has 2 fields, a drop-down field and a checkbox field. The checkbox field has a single option to select from. I am looking for a way so that if any row is checked, that all of the rows after it are automatically checked as well. For example, if row 1 and 2 are filled in and on row 3 the checkbox is checked, then row 4, 5, etc. would automatically be checked if they already exist or if the are added. Any ideas how I would go about doing that?

1 0

Replies

replied on April 27, 2018

Hi Blake,

You can try custom script like this: (add CSS class 'myTable' to the table field)

$('document').ready(function(){
  $('li.myTable').change(function(e){
    var changedElm = $(e.originalEvent.target);
    if (changedElm.attr('type') == 'checkbox') {
      var checkboxBelow = changedElm.closest('tr').nextAll().find('input[type=checkbox]:visible');
      checkboxBelow.each(function(i, checkbox){
        if (!$(checkbox).is(':checked')) {
          $(checkbox).click();
        }
      });
    }
  });
});

The script doesn't handle the case if newly added rows should be checked, or if unchecking one should uncheck all below it. It depends on your design.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.