Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic text in layer

Status
Not open for further replies.

Microbe

Programmer
Oct 16, 2000
607
AU
Hello folks,

I have an image - a map - that I want to display a name when ppl mouseover a location. I have created a layer that is hidden off the page and onMouseOver it moves to the right position. So far so good.

The problem lies in that there are 66 locations. I could make 66 different layers but that seems a) prone to error and b) way too fat code.

I would prefer to have one layer and change the text depending on which location is pointed at.

So far I have:

<script language=&quot;JavaScript1.2&quot;>

function moveLayer(title){

Layer1.style.top='200'
Layer1.style.left='200'

}
function hideLayer(){
Layer1.style.top='-300'
Layer1.style.left='-300'
}

to do the work

and 66 lines that look something like:
<area shape=&quot;rect&quot; coords=&quot;-13,489,8,504&quot; href=&quot;#&quot; onMouseover=&quot;moveLayer()&quot; onMouseout=&quot;hideLayer()&quot; >

I am picturing using movelayer('location1') etc but my Javascript knowledge is limited to not knowing how to change the text when the layer comes in as it has already been written when the page is created in the browser.

I know more about ASP, but then get stuck in calling the mouseover event in JS but triggering something in ASP. Help??

Thanks

Steve Davis
hey.you@hahaha.com.au
 
If you give the layer an ID you can use innerHTML to change it... For example, if the layer's id is &quot;layer1&quot;, you can add the following to your moveLayer function:
document.getElementById(&quot;layer1&quot;).innerHTML = title

This works in IE5+ and NS6+...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top