A little new to javascript? Anyways, you cannot document.write once the page is loaded without overwriting the page, wiping out everything else. I'm not sure what part an array needs to take in this either, though that part seems workable, just that I think it can be accomplished with strings, and that there is no real advantage in using an array(s). I'm not even certain I 100% understand what you want, but I'm pretty sure I get most of it.
You say you have links or buttons with id's that represent the image's filename minus both the path and extension. If all images are in the same folder and all have the same extension, strings will suffice for adding that information. You can setup a container with an image in it, the src attribute can be either a blank image or one that you would like loaded when the page first loads, ex:
HTML Code:
<div><img id="displayImage" src="blank.gif"></div>
You could have a button:
HTML Code:
<input type="button" id="neat_picture" onclick="idisplay(this);">
Say the path to your images is /images/show_2/ and they are all .jpg:
Code:
function idisplay(el){
document.getElementById('displayImage').src='/images/show_2/'+el.id+'.jpg';
}
That will load:
/images/show_2/neat_picture.jpg
into the id="displayImage'" img tag. You can have as many of those buttons as you like, each with a different id corresponding to a different image.
The main problem with this is that it is inaccessible to folks without javascript enabled. You cannot make it accessible to those folks without one of the following:
- Server side code
- A link that contains the full path to the image as its href.
Bookmarks