orhor
07-04-2005, 10:55 AM
Hi,
this is my question, I wrote a script that generates new IMGs in my page. I need to add a onClick property to these newly generated images. I would like to have some javascript solution, that would work the same way like if the images would be written in HTML they had these tags: <img onClick='javascript: myFunction("thisImageId");'>
this is a part of my code:
function addNewImg(newImageId){
newImg = document.createElement('img');
newImg.id = "image"+newImageId;
newImg = document.getElementById("divimage1").appendChild(newImg);
document.getElementById("image"+newImageId).onclick=ppEdit("image"+newImageId,"image"); // this is the line that doesnt work for me
}
sorry for my english, any help will be greatly appreciated
this is my question, I wrote a script that generates new IMGs in my page. I need to add a onClick property to these newly generated images. I would like to have some javascript solution, that would work the same way like if the images would be written in HTML they had these tags: <img onClick='javascript: myFunction("thisImageId");'>
this is a part of my code:
function addNewImg(newImageId){
newImg = document.createElement('img');
newImg.id = "image"+newImageId;
newImg = document.getElementById("divimage1").appendChild(newImg);
document.getElementById("image"+newImageId).onclick=ppEdit("image"+newImageId,"image"); // this is the line that doesnt work for me
}
sorry for my english, any help will be greatly appreciated