Name: Anonymous 2011-04-13 14:59
hey /prog/,
I'm experimenting with html5 & friends, and I've run into a problem which you might be able to help me with...
I'm trying to use a <def> <circle> svg elements, placing it 4 times using the <use> tag with a unique id for each, then adding an onClick function so when I click each of the circles an alert tells me the unique id of each circle...
I've got everything fine, except instead of the unique id, I get told the id is "undefined"...
searching for "use" and "def" don't really return any helpful results in google/etc since it's too vague.
currently the relevant parts of my code look like:
for the circle definition:
<defs>
<circle id="tBack" style="fill:daa;" cx="60px" cy="60px" r="50px"/>
</defs>
the <use> for circle instances:
<use id="circleAA" onclick="clicked(evt)" xlink:href="#tBack"/>
<use id="circleCA" onclick="clicked(evt)" xlink:href="#tBack" x="220" y="10"/>
etc...
and the onclick javascript:
function clicked(evt){
alert(evt.target.id);
}
thanks for your time and any help given.
I'm experimenting with html5 & friends, and I've run into a problem which you might be able to help me with...
I'm trying to use a <def> <circle> svg elements, placing it 4 times using the <use> tag with a unique id for each, then adding an onClick function so when I click each of the circles an alert tells me the unique id of each circle...
I've got everything fine, except instead of the unique id, I get told the id is "undefined"...
searching for "use" and "def" don't really return any helpful results in google/etc since it's too vague.
currently the relevant parts of my code look like:
for the circle definition:
<defs>
<circle id="tBack" style="fill:daa;" cx="60px" cy="60px" r="50px"/>
</defs>
the <use> for circle instances:
<use id="circleAA" onclick="clicked(evt)" xlink:href="#tBack"/>
<use id="circleCA" onclick="clicked(evt)" xlink:href="#tBack" x="220" y="10"/>
etc...
and the onclick javascript:
function clicked(evt){
alert(evt.target.id);
}
thanks for your time and any help given.