Thanks,
For the reply but I googled and I got the solution.
var str = [];
function selectContractors(pID) {
var test = $.map($('input[id="'+pID+'"]:checked'), function (c) { return c.value; });
if(test.length > 0)
{
str.push(pID);
}
else
{
str.splice(str.indexOf(pID),1);
}
}