if it's just a matter of fixing your code, then you might actually want to show us your implementation on your app online! you might have missed something.
and without a review on your implementation we can' t actually figure out what went wrong.
Furthermore for a suitable solution, it is required for us to understand what you are aiming for, with the selected IDs.
Is it just for the solo purpose of displaying them? or are you processing those IDs in a PL/SQL Process?
Base on your answer we might have a better approach for you.
I'm on apex 5 and need to get the ids of the selected rows, but this just work when i select all the rows, this is the page where i got the code and this is my problem:
I already have the same code in another page an they are the same
We can not debug something we can not see. You could try to replicate your use case over on apex.oracle.com and share credentials so that someone could have a look at it and try to find a solution.