Ok, I don't know what you want to do this for so I can only help so much!!
<script language="javascript">
var i;
var newarray = new Array()
for (i = 1; i <= 7; i++)
{
if (i == 1)
{
newarray[i] = "pic" + i + ".src=bild[num].src;"
}
else
{
newarray[i] = "pic" + i + ".src=bild[num+" + (i - 1) + "].src;"
}
}
</script>
Ok this formulates those lines you want into strings. The reason the for loop contains an if, else pair is because of the naming convention you have used. The first one doesn't contain a number next to num:
pic1.src=bild[num].src;
If that contained zero, then this code could be altered, and made shorter, so as to exclude the if, else pair.
If I knew exactly what it is you were doing I may be able to help you better, as it stands this forms what you wanted into a series of strings stored in an array. You can see this if you run the code below (after the code above of course):
var j;
for (j=1; j < newarray.length; j++)
{
document.write(newarray[j] + "<br>")
}
Bookmarks