I know this is bad code but my thoughts were that go to the state details and run the function update with the id of the entry. Then switch trough the id and update the view based on the clicked element.

The code works fine, but i think there is a much better way to do it and i need it dynamically.

I'm really stuck with this and would like to do it correctly. How should it be made? Can you give me a hint please?