0

I have a Gridview, each row with two check box, on the check of second checkbox i want the first check box to be checked automatically.I'm looking for Clent side scripts...Please help

1
  • If you are using jQuery you can write function which will iterate through your table and bind change event of each second checkbox. Commented May 28, 2012 at 6:09

1 Answer 1

1

Try this

var rows = $("#your table tr:gt(0)"); // skip the header row

rows.each(function(index) {
    var lastCheckbox = $("td:nth-child(youlast checkbox cell) input", this);
    var firstCheckBox=$("td:nth-child(firstCheckboxCellIndex) input", this);
    $(lastCheckbox).change(function(e) { $(firstCheckBox).attr('checked',$(this).is(':checked'));
});;
Sign up to request clarification or add additional context in comments.

1 Comment

hi i chnaged the code like this $(document).ready(function () { var rows = $("#GrdMenuConfig tr:gt(0)"); rows.each(function (index) { var lastCheckbox = $("td:nth-child(4) input", this); var firstCheckBox = $("td:nth-child(3) input", this); $(lastCheckbox).change(function (e) { $(firstCheckBox).attr('checked', $(this).is(':checked')); }); }); }); but it doesn'tworks...!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.