W3C home > Mailing lists > Public > www-svg@w3.org > April 2002

Getting a handle to a text element using ecmascript...

From: SANSONE, AARON M [Non-Pharmacia/1000] <aaron.m.sansone@monsanto.com>
Date: Fri, 12 Apr 2002 16:24:36 -0400
To: "'www-svg@w3.org'" <www-svg@w3.org>
Message-ID: <6A1BB598448ED31198DC0008C75B715309A49200@ems1000-05.monsanto.com>
I have a very simple x-y graph with points.  I am attempting to change the
value of a text element that appears at the top of the graph with the name
of the point that the mouse moves over.  Is there a simple way to reference
the <text> element from the script using an id or class attribute?

Here is the SVG Document...the changeName function obviously doesn't work
and is the problem I am trying to solve.

Thanks,

-Aaron


<?xml version="1.0" encoding="UTF-8"?>
<svg width="400" height="400">
	<title>Graphed Pointer Events Test</title>

	<defs>
		<script type="text/ecmascript">
			function changeName(name) {
				text.individual.setValue(name);
			}
		</script>
	</defs>

	<g>
		<text id="circleName" x="180" y="20"
font-family="Verdana" font-size="14" fill="black">POINT-0</text>	
	</g>

	<g id="axis" stroke="black" >
		<line x1="20" y1="0" x2="20" y2="380" stroke-width="2"/>
		<line x1="20" y1="380" x2="400" y2="380" stroke-width="2"/>
	</g>

	<g>
		<circle cx="60" cy="20" r="1" fill="red" stroke="black"
stroke-width="1" onmouseover="changeName('POINT-1')"/>
		<circle cx="60" cy="40" r="1" fill="red" stroke="black"
stroke-width="1" onmouseover="changeName('POINT-2')"/>
		<circle cx="60" cy="60" r="1" fill="red" stroke="black"
stroke-width="1" onmouseover="changeName('POINT-3')"/>
		<circle cx="60" cy="80" r="1" fill="red" stroke="black"
stroke-width="1" onmouseover="changeName('POINT-4')"/>
		<circle cx="80" cy="80" r="1" fill="red" stroke="black"
stroke-width="1" onmouseover="changeName('POINT-5')"/>
	</g>

</svg> 
Received on Friday, 12 April 2002 16:25:30 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:22 GMT