I'm new to JavaScript. I've already used Java and C# (and a bit of c++)
So far..
I'm using JavaScript to load pictures from a directory into an Array. After this I want to place this pictures on my page.
This works already.
The next step was to add a fullscreen function, to load the picture in fullscreen resolution.
var myfiles;
var pfad = "./bilder/" //directory of the images
var index = 0;
myfiles = new Array(); //String array with the names of the pictures
myfiles[0] = "01.png";
myfiles[1] = "01.png"; //usw.
myfiles[2] = "03.png";
myfiles[3] = "02.png";
function fullScreen(bild) {
document.write('<img src="'+ pfad + bild + '" border="0" width="100%">');
alert (bild);
}
function start() {
for(var i=0; i < myfiles.length; i++) {
pics[i].src = pfad + myfiles[i];
string = myfiles[i];
document.write('<img onclick="fullScreen(string);" src="'+ pfad + myfiles[i] + '" border="0" height="150px" >');
}
}
This code only loads the last picture of my array..
The function fullScreen()
seems to take only the last value of string.
The HTML part
<script type="text/javascript">
start();
</script>