Trying to display images using 2 folders

I have 2 folders forlder1 and folder2 both have different images
i m trying to show a random image from folder1 using onclicked event i have a button which i m using for onclick event i want to show that random image from folder 1 when i press this button but i cant seem to get the logic for it