Click here to Skip to main content
15,173,299 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a dynamic grid. The structure of the grid is as follows:

Serial No                  Document Name       Attachment
1(checkbox)                  abc               (img)
2(checkbox)                   xyz               (img)
3(checkbox)                   uio               (img)
4(checkbox)                   pop               (img)
Against every serial number there is a checkbox. And in attachment column when you click the image it opens a dialog box which shows the documents attached against this document. Each attachment also has a checkbox against it.

This dialog box is another table and comes from another dynamic grid.

What I want to do is that when selecting the first checkbox which is against the first serial number(1) I want the checkboxes in the same dialog to be checked as well. And if the user selects checkbox against serial number and then click on that dialog box against that serial number and uncheck all checkboxes then the checkbox against serial number 1 should also be unchecked.

I tried doing this using the closet table function.

Below is the code

    $('.activity_selection').live('click', function (e) {
        var table = $('table');
        $('td input:checkbox', table).attr('checked',;


I know how to access a td in the same tr but accessing the controls of dialog box on an on click function, I am clueless. 
.activity_selection is a class that I have given to checkboxes against serial numbers. But it selects all the checkboxes against all serial numbers that is 1 to 4. What I want is that it checks only checkboxes in the current dialog box? How can I achieve this using javascript or jquery? I have many other sample code but it did not work. Please help.

What I have tried:

Below is the code

    $('.activity_selection').live('click', function (e) {
        var table = $('table');
        $('td input:checkbox', table).attr('checked',;

Updated 10-Jun-21 5:18am
jaket-cp 11-Jun-21 5:51am
It would help if the hmtl markup was also supplied in the question.
Also really depends on how the image is linked to the dialog box.
Assuming the image click opens different dialog box tables with the checkboxes.
This is usually performed with the elements unique id.
Can the dialog box id be determined before hand?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900