rlincolnh
11-28-2004, 06:33 AM
I have many areas defined in an image, and a single onmouseover handler. I need to have a number of different data items associated with each area and be able to access those data from within the handler. So at the beginning we define something like this:
<AREA id="defaultmode" onMouseover="maplinkover(event)" ...>
<AREA id="mode1" onMouseover="maplinkover(event)" ...>
var defaultmode=[value1, value2, value3, ...];
var mode1=[value5, value6, value7, ...];
Then in the onmouseover handler I retrieve the id of the area that triggered the event (say it was "mode1") and then want to do things like:
instrument_set=mode1[0]; power_level=mode1[1]; etc.
But of course the id is just a string 'm' 'o' 'd' 'e' '1' and has no relationship to the variable mode1.
My question: How do I make that association? I realize that I could spin around in a loop comparing the id to an array of id strings, hence forming an index that I could use to access another array (or array of arrays) to get the data that I want, but that seems extremely messy, inelegant, and a nightmare-in-waiting for when I need to add, alter, or delete areas and values.
I'm sure there must be a better way - help, anyone, please?
<AREA id="defaultmode" onMouseover="maplinkover(event)" ...>
<AREA id="mode1" onMouseover="maplinkover(event)" ...>
var defaultmode=[value1, value2, value3, ...];
var mode1=[value5, value6, value7, ...];
Then in the onmouseover handler I retrieve the id of the area that triggered the event (say it was "mode1") and then want to do things like:
instrument_set=mode1[0]; power_level=mode1[1]; etc.
But of course the id is just a string 'm' 'o' 'd' 'e' '1' and has no relationship to the variable mode1.
My question: How do I make that association? I realize that I could spin around in a loop comparing the id to an array of id strings, hence forming an index that I could use to access another array (or array of arrays) to get the data that I want, but that seems extremely messy, inelegant, and a nightmare-in-waiting for when I need to add, alter, or delete areas and values.
I'm sure there must be a better way - help, anyone, please?