And here's the function (currently one for each div):
---
function hiA() {
allplain();
document.getElementById('mapA').style.backgroundImage = 'url(images/locale_lg-hi.png)';
document.getElementById('mapA').style.color = '#fff';
document.getElementById('legA').style.backgroundImage = 'url(images/locale_lg-hi.png)';
document.getElementById('legA').style.color = '#fff';
document.getElementById('itemA').style.backgroundColor = '#f6e3ab';
}
---
I made a function for each div; hiA(), hiB() and so on.
What I want to do instead is call the function like so on the web page:
---
onmouseOver="hi(A);return false;
---
(changing (A) to (B) etc as required for each instance)
and
function hi()
using the parameter passed from the web page to populate the Id's in the script (e.g. 'mapA', 'legA' etc).
I've seen this done before, but can't call to mind any useful examples, or work out the syntax on my own.
Personally, I prefer to abstract everything to the DOM and get rid of inline calls. But that's a little more complex, and you may violently disagree.
function hi(suffix) { allplain(); document.getElementById('map' + suffix).style.backgroundImage = 'url(images/locale_lg-hi.png)'; document.getElementById('map' + suffix).style.color = '#fff'; document.getElementById('leg' + suffix).style.backgroundImage = 'url(images/locale_lg-hi.png)'; document.getElementById('leg' + suffix).style.color = '#fff'; document.getElementById('item' + suffix).style.backgroundColor = '#f6e3ab'; }
onmouseOver="hi('A');return false;