Individual layers within a map service can be turned on or off using the esri javascript api. Look at the setVisibleLayers method of the dynamicmaplayer class: https://developers.arcgis.com/javascript/3/jsapi/arcgisdynamicmapservicelayer-amd.html#setvisiblelayers
It takes on array of layerIDs to make visible
require([
"esri/layers/ArcGISDynamicMapServiceLayer" ,"dojo/query", ...
], function(ArcGISDynamicMapServiceLayer, query, ... ) {
var layer = new ArcGISDynamicMapServiceLayer( ... );
var inputs = query(".list_item"), input;
visible = [];
for (var i=0, il=inputs.length; i< il; i++) {
if (inputs[i].checked) {
visible.push(inputs[i].id);
}
}
layer.setVisibleLayers(visible);
...
});