I need to modify this function:
function checkPermissions(fid, obj) {
$("#permissions_"+fid+"_canview").attr("checked", obj.checked);
}
if the param "n" is "true" then instead of #permissions it'll output #permissionsSet.
is that possible?
OP clarified the question to be change this whether or not a 3rd parameter was provided. Here you go.
function checkPermissions(fid, obj, n) {
var id = n !== undefined ? '#permissionsSet' : '#permissions';
$(id + fid + "_canview").attr("checked", obj.checked);
}
Note: This function can be freely used with passing 2 or 3 parameters (or really any number).
checkPermissions(1, this); // Ok n === undefined
checkPermissions(1, this, true); // Ok n === true
checkPermissions(1); // Okish n and obj === undefined
onClick="checkPermissions('.$gid.', this);"onClick handler. You need to make sure the function is defined before the element to which you attach the handler
ifstatement?