JScript Images annoying me

by "Angie Michaels" <angiemichaels(at)blueyonder.co.uk>

 Date:  Fri, 27 Apr 2001 08:24:55 +0100
 To:  <hwg-languages(at)hwg.org>
  todo: View Thread, Original
This is really starting to bug me now.

I have an image in a table.
<IMG SRC="initial.jpg" NAME="imgdisp">


On load the following script is executed :-

function MyLoad() {
var pics = new Array(<%=latestarr%>)
for ( var i = 0; i < pics.length ; i++ ) {
Mpics[i] = new Image() ;
Mpics[i].src = pics[i]
}
}

latestarr is an array generated from a DB and the result before JavaScript
execution is :-

"stock/thumb/test.jpg","stock/thumb/Write.jpg","stock/thumb/read.jpg"

Once that has been read I want a link to change the image in the table
according to the value within the links which looks like this :-

<A HREF="testlink.asp" ALT="" OnMouseOver="return MyM(0); return
true;">test</A>

where in this case 0 is the image array value. The reason for this is that
the value '0' will be generated by ASP eventually. The MyM script is below
:-

function MyM(pic) {
document.images[imgdisp].src = Mpics[pic] ;
}

>From what I understand about JScript, which isn't a lot, is that the first
script should load the images listed in the 'latestarr' array into the
JScript 'Mpics' array, then when the mouse is put over the link the MyM
script should replace the existing image with the one corresponding to the
array value sent from the link. There are no errors showing but having used
an alert function after the image should have been changed I see that it
shows Mpics[pic] as [object] and not the actual value I want which would be
stock/thumb/test.jpg .

Right clicking on the replaced image which actually shows that nice red "x"
image of IE's the source shows that the source is [object]

Any help would be appreciated here, I',m running out of hair :/

TIA
Angie

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA