Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Processing an array through a OnMouseOver event? 1

Status
Not open for further replies.

pkirkley

Programmer
Sep 6, 2001
12
0
0
US
I am trying to process through an array of images but my index isn't working the way I thought it would. Here is the code:

<script language=&quot;JavaScript&quot;>

var image_names = new Array(&quot;AA_0_001.jpg&quot;,&quot;AA_0_002.jpg&quot;,&quot;AA_0_003.jpg&quot;,&quot;AA_0_004.jpg&quot;,&quot;AA_0_005.jpg&quot;,&quot;AA_0_006.jpg&quot;,&quot;AA_0_007.jpg&quot;,&quot;AA_0_008.jpg&quot;,&quot;AA_0_009.jpg&quot;,&quot;AA_0_010.jpg&quot;,
&quot;AA_0_011.jpg&quot;,&quot;AA_0_012.jpg&quot;,&quot;AA_0_013.jpg&quot;,&quot;AA_0_014.jpg&quot;,&quot;AA_0_015.jpg&quot;,&quot;AA_0_016.jpg&quot;,&quot;AA_0_017.jpg&quot;,&quot;AA_0_018.jpg&quot;,&quot;AA_0_019.jpg&quot;,&quot;AA_0_020.jpg&quot;,&quot;AA_0_021.jpg&quot;,&quot;AA_0_022.jpg&quot;,
&quot;AA_0_023.jpg&quot;,&quot;AA_0_024.jpg&quot;,&quot;AA_0_025.jpg&quot;);
var a_image;
var image_index = 0;

function nextPic(image_index) //Function
{
// process forward through image array and display image to target frame for page,

if (image_index > image_names.length)
{
image_index = 0
parent.target.document.target_pic.src = image_names[image_index];
}
parent.target.document.target_pic.src = image_names[image_index];

image_index++;
}

</script>

</head>

<a href=&quot;#&quot; onClick=&quot;nextPic(image_index); return false;&quot;>Next</a>

What is not correct with this logic?
Thanks for any help!!

 
hi
may be it is that you aren't using the hole syntax?

parent.frames.target.document.images.target_pic.src = image_names[image_index]

or if you're writing it for netscrap, & image is inside a layer, it is even uglier:

parent.frames.target.document.layers.layername.document.images.target_pic.src = image_names[image_index]
Victor
 
TechnicalAnalysis,

Yes I get the first image every time. It seems that the index is always getting reset to '0' even though the var is outside to function nextPic(). Any thoughts?

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top