Changing text on mouse click

skeg_13
05-19-2004, 06:30 PM
Hello All,
I am tryin to dynamically change the value of some text in my svg file.


function Stop_Clicked(evt)
{
var stop = evt.target;
if ( window.svgDocument == null )
svgDocument = evt.target.ownerDocument;

var id = stop.getElementID;
var text = svgDocument.getElementById("text"); //text is the name of my tspan element
if (id == "city_hall")
{
text.data = "You clicked City Hall";
}
}



where the text element is


<text>
<tspan id="text"></tspan>
</text>


please help,

Greg

Anonymous
05-20-2004, 01:15 AM
First, getElementID doesn't exist ( in ASV )
Replace by
var id = stop.getAttributeNS(null,"id")
Second, you have to put your text as first child of your tspan, but if you give empty text child doesn't exist. So put space as text
<tspan id="text"> </tspan>
And add firstChild in script
text.firstChild.data = "You clicked City Hall"

This run in ASV3 ....

Michel

 
Web mp2kmag.com
mapforums.com

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum