I have a project where I need to be able to control four things onClick. I have a set of 12 arrows (3 colors, 4 directions) and I need to specify the XY coordinate of the arrow tip and I need to call the arrow by color and direction (instead of by src). Is this something that I can do with a 2d array?
My Java looks like this:
function ixycoord(i,x,y) {
document.images["baseimage"].src = i;
if (document.getElementById)
{document.getElementById("baseimage").style.top = y;
document.getElementById("baseimage").style.left = x} else
<p>This is a the <a href="#n" onClick="ixycoord('whiteup.png',49,57)"> aorta</a>. This is the <a href="#n" onClick="ixycoord('blueleft.png',145,144)"> ventricle </a> and this is the <a href="#n" onClick="ixycoord('redright.png',220,230)">pericardium</a>. </p>
I have to be able to make it *NOT* have the the image source in the onClick. Thanks in advance for any help you can give me!
I apparently wasn't clear enough. All of the arrows point to the correct spot. The code works just fine, everything does exactly as it is supposed to. The alternate arrows are stored in a folder and are successfully called and put in the correct place based on the XY coordinates. The code is fine.
My problem is:
My boss thinks it is too cumbersome to have to write the image name each time. That is he thinks, IXYcoords ("image.png", 345, 454) etc. is too cumbersome. Instead he wants four points (color, direction, x, y).
So let's say we have 12 arrows labeled by (3) color and (4) direction.
whiteup.png, bluedown.png, etc.
I need to have the arrows called by (white, down, 384, 472). Can I do this with an array of some sort?
Not sure I understand the need of an array...
Add to JS
Code:
function pic(iColor, iDirection) { return iColor+iDirection+'.png'; }
Change HTML
Code:
<p>
This is a the <a href="#n" onClick="ixycoord(pic('white','up'),49,57)"> aorta</a>.
This is the <a href="#n" onClick="ixycoord(pic('blue','left'),145,144)"> ventricle </a> and
this is the <a href="#n" onClick="ixycoord(pic('red','right'),220,230)">pericardium</a>.
</p>