Setting a checkbox to "checked"
Setting a checkbox to "checked"
martinadams
Posts: 2Questions: 0Answers: 0
Allan, what an amazing technology you created. I'm impressed and wish you best of luck with it. I'll donate as soon as I'm ready to launch.
I'm trying to set a checkbox to "checked" once another checkbox in the same row has been set to "checked" as well. Here's the code:
[code]
$('input').bind('click', function () {
oTable.fnSort( [ [1,'asc'], [2,'desc'], [5,'desc'], [3,'desc'], [4,'desc'], [6,'asc'], [7,'desc'] ] );
var thisrow = $(this).closest("tr").get(0);
var aRow = oTable.fnGetPosition(thisrow);
var aData = oTable.fnGetData( aRow );
if (aData[3] == 1) {
aData[4].attr('checked', true);
}
});
[/code]
The .attr() function doesn't seem to work. I scoured the entire forum, but couldn't find a way to make this work.
Any ideas?
Thanks much,
Martin
I'm trying to set a checkbox to "checked" once another checkbox in the same row has been set to "checked" as well. Here's the code:
[code]
$('input').bind('click', function () {
oTable.fnSort( [ [1,'asc'], [2,'desc'], [5,'desc'], [3,'desc'], [4,'desc'], [6,'asc'], [7,'desc'] ] );
var thisrow = $(this).closest("tr").get(0);
var aRow = oTable.fnGetPosition(thisrow);
var aData = oTable.fnGetData( aRow );
if (aData[3] == 1) {
aData[4].attr('checked', true);
}
});
[/code]
The .attr() function doesn't seem to work. I scoured the entire forum, but couldn't find a way to make this work.
Any ideas?
Thanks much,
Martin
This discussion has been closed.
Replies
That data array from fnGetData is just an array of strings, not the TD (or more importantly in this case INPUT) elements. So what I think you'll need to do is something like $('input', this.parentNode.parentNode).attr('checked', true); . This will get all input elements (you might need to refine it) of the parentNode's (TD) parentNode (TR) (again if you have your checkboxes buried down deeper, it's probably worth using the jQuery parent() or find() methods).
Hope this helps.
Allan
Martin