Hello, I am trying to create a rollover on a stock index graph when I rollover one of three geographic areas (Americas, Asia, Europe) on a separate image . So far I have been only able to create the rollover for the separate countries, without the second image. Here is the code I found and adapted:
<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
Also, I have been able to connect the two images by using the following code, but this only allows viewing two regions/corresponding graphs, instead of three - and it works only by rolling over the entire tab graph, instead of specific regions (hotspots):
Thank you so much for your reply - you have a very quick eye for detail.
The reason why I didn't go with the second method is that it does not allow to put hotspots on each region (Americas, Asia, Europe). I need some sort of way of combining the two methods (i.e. rolling over two images synchronously). I put the third pair in the function when I was playing around with it - but it does not seem to effect the function when using 2 pairs.
You are absolutely correct that I need only two rollovers, so my difficulty is not with passing a third pair, but with getting OnMouseOver to perform two functions at once. Or could there be a different, and more elegant solution?
My knowledge in programming is very basic - please excuse.
In case it may be able to help - here is the site where the two versions of the code are placed: http://saedias.blogspot.com/
The graph is located on left-hand side right below the profile info. Again, I'd like to have the ability to use the tab with the three regions as hotspots that link to the appropriate graphs. The graph below the tab only allows viewing two regions and it works by rolling over the entire tab, instead of the region-specific hotspots.
Okay, so the idea is that when the person rolls over "Americas" then the stock chart for "Americas" appears. Ditto for "Europe" and "Asia". Right??
But *WHY* do you then want to REVERT BACK to the prior image when you mouse off one of the words??? Why not just leave the current stock there, as is??
So why do we need any "image map"? Why can't we just use <span>s and be happy? And what is the URL of the third graph??? I can't demo the code to you with only the two images.
************
Incidentally, your page there has a virus. When I right-clicked and downloaded the image file (HP_NKY.png), it also tried to hand me a Trojan virus that my virus scan software detected and killed.
You need to clean up that page and/or site, it would seem.
Surely lots and lots of other ways to do this, but this scheme is actually very efficient. Ensures that the images will all be there when the mouse is used, for example.