var total_images = 3; var random_number = Math.floor((Math.random()*total_images)); var random_img = new Array(); random_img[0] = ''; random_img[1] = ''; random_img[2] = ''; document.write(random_img[random_number]);