Thursday, November 26, 2009

Javascript function check data exist in array

function isexist(id, list) {
$.each(list, function(i, temp) {
if (id == temp) {
return true;
}
});
return false;
}

Tuesday, November 24, 2009

Javascript to sort any list of object

function myBubbleSort(arrayName, length) {
for (var i = 0; i < (length - 1); i++)
for (var j = i + 1; j < length; j++)
if (arrayName[j].CommentId < arrayName[i].CommentId) {
var dummy = arrayName[i];
arrayName[i] = arrayName[j];
arrayName[j] = dummy;
}
}