Topic: Image name in hidden variable

i have a requirement where i want the user to edit the selected image. This will be done on a seperate page by a different component. But i want to know which image is selected currently.

So i want that when the user clicks on a thumbnail the image name is set in an hidden html variable. This way i will know the image name and i can allow the user to edit it via a link on a page. In short i want to programatically know the name of the image that is selected.