I'm building a project review form, and wanted to include a "Next" and "Previous" button (and possibly a dropdown to choose a project id/title to jump to).
I can do a redirect to the current ID +/-1, but wondered if there was a way to check if a particular ID exists, before redirecting to that ID? Or to get a list of item IDs ?
So if I have items with ID 1,2,4,5,7, and I'm on 4, the next won't be a problem (ID+1=5), but previous would be ID-1=3, which no longer exists. Any ideas how to check if 3 exists, and if it doesn't, go to ID-2 instead (and then ID-3 if that doesn't exist)?
This would be a really useful feature that would save our project managers a lot of time!