Hi all,
i've got another problem. it's based on the question i asked before about creating a onclick-property using javascript.
now what i want to do is create multiple divs with an onclick-property using a for-loop and a 2D array.
problem is, the onclick always sends the value of the last created div rather then the value of the div i've clicked on. the strange thing is that all other properties are added fine.
does anyone know whats causing this and how to fix it?
i've got another problem. it's based on the question i asked before about creating a onclick-property using javascript.
now what i want to do is create multiple divs with an onclick-property using a for-loop and a 2D array.
Code:
for(var m = 0; m < inputdivs.length; m++){
var arr = inputdivs[m];
var newd = document.createElement("div");
newd.innerHTML = arr[0];
newd.style.width = arr[1];
newd.style.height = arr[2];
newd.style.top = arr[3];
newd.style.left = arr[4];
newd.style.position = "absolute";
newd.style.fontWeight = arr[5];
newd.style.fontStyle = arr[6];
newd.style.color = arr[7];
newd.style.textDecoration = arr[8];
newd.style.fontSize = arr[9];
newd.style.textAlign = arr[10];
newd.style.verticalAlign = arr[11];
newd.id = arr[12];
newd.style.border = "solid 1px #BBBBBB";
newd.onclick = function(){myFunct(arr[12])};
newd.onmouseup = function(){myProb(arr[12])};
$("foo").appendChild(newd); //this is prototype meaning document.getelementbyid()
}
does anyone know whats causing this and how to fix it?
Comment