You don't need to use loop since you already got the elements (markers) by ID. So you just check if the player is within them.
function duty(thePlayer)
local checkjob = getElementByID("1")
local checkjob2 = getElementByID("2")
if type(checkjob) == "marker" and type(checkjob) == "marker" then -- just to be sure they are markers
if isElementWithinMarker(thePlayer, checkjob) then
outputChatBox("1 job", thePlayer, 255, 0, 0)
elseif isElementWithinMarker(thePlayer, checkjob2) then
outputChatBox("2 job", thePlayer, 255, 0, 0)
else
outputChatBox("not marker", thePlayer, 255, 0, 0)
end
end
end
addCommandHandler("duty", duty)