1
I want to print the values of an array that are pushed every time I click on an object. The function works because Alert appears. The problem is that it does not print the values in the html paragraph.
var x1;
var y;
shape.onclick = function(){
var name=this.id;
alert(name);
x1=this.getAttributeNS(null, "cx");
y=this.getAttributeNS(null, "cy");
alert(y);
namecirc=push(name);
positionX=push(x1);
positionY=push(y);
document.getElementById("demo").innerHTML ="x="+positionX;
};
html:
<p id="demo"></p>
Where are these "arrays" located? For example:
positionX
is already an array? if it is should use not equality but yespositionX.push(x1);
There’s more code missing here?– Sergio
Yes is an array set on top of the code, var positionX = new Array();
– akm
And what do you want to show in
demo
? the array with all or only the last positions?– Sergio
all positions, changed to positionX.push(X1), still does not show.
– akm