I construct an array, which I am going to use later to compare some values. I use this code to construct "myArray", which I am going to use later:
var optionTexts = [];
$('#stripeMeSubSubCat tr').each(function(){
if ($(this).find('input:checkbox.subsubcat_chkclass:not(:checked)').length == 0)
{
subsubrow_cat_id_no = parseInt($(this).closest("tr").attr("id"));
optionTexts.push(subsubrow_cat_id_no);
};
});
var myArray = optionTexts.join(', ');
alert("myArray = "+myArray);
Here I use myArray to make a comparison:
$('#stripeMeSubSubCat tr').each(function(){
myindex = $.trim($(this).closest("tr").attr("id"));
var arr = [myArray];
//var arr = [0, 439, 52, 53];
myindex = parseInt(myindex);
alert(myindex);
alert(arr);
if ((jQuery.inArray(myindex, arr)) == -1) {
var equal = "FALSE";
} else {
var equal = "TRUE";
$("#stripeMeSubSubCat tr[id='" + myindex + "'] input").attr('checked', true);
};
alert(equal);
});
As is the code above it always returns FALSE. However, if don't use the first chunk of code and just enable the commented out var arr (where I set the array to fixed data) it returns TRUE where it should.
Any ideas?