Need help on building random dynamic table

Having some troubles trying to build a dynamic table in Corona - any help or idea would help.

Here is the problem - building a button game

*can have from 4 to 24 images - (or really 2 to 12 pairs) - user inputs value

*can display images from different folders (for examples - cars, trucks, boats - will have 50 images each) - user inputs value

*if the user picks 16 and cars, I want to grab 8 random car images and load them in onto the screen using the random number value (i.e. 1.png, 3.png, 4.png, 8.png, 11.png, 12.png, 24.png, 45.png)

something like this
local buttonImages = {1,1, 3,3, 4,5, 8,8, 11,11, 12,12, 24,24, 45,45);

So, what is the best way in Corona to handle this? Any help is greatly appreciated.
[import]uid: 115952 topic_id: 20729 reply_id: 320729[/import]

To create the random table:

  
myTable = {} --holds the random numbers  
  
for i = 1,myNumber do -- where myNumber is the number of images selected by the user  
  
 myTable[#myTable + 1] = math.random(1,50) -- assign next slot in table random # from 1 to 50  
  
end  
  

to display images:

  
for j = 1,#myTable do --iterate through table  
  
 obj = display.newImage(myFolder.."/"..myTable[j]..".png",x,y) -- where myFolder is folder holding the images  
  

That should get you started. [import]uid: 64596 topic_id: 20729 reply_id: 81431[/import]