Javascript drop down menu and pagination

Is it possible to use javascript to populate the drop down menu instead of hardcoding? I already called the images dynamically and all, but I don’t know how to call the drop down menu dynamically based on the images uploaded to my folder.

I’m also having trouble scripting the pagination for my code. I don’t know how to display my images in boxes that has same distance between each and shows only 6 to 8 images at a time. Since right now, my images are all stuck together next to each other with out a border between or being centered and showing all images.

I’m new to javascript and have been stuck on this for about 2 weeks now. I really hope someone can help me out and give me some examples to work with if possible.
Thank you

Can you send a link to the page that you are developing? It would help if we can see what you are doing.