View Full Version : image disappear when clicking ?

10-30-2006, 10:39 PM
i'm developing an image gallery.
i've added an option to change to border of a thumbnail (to highlight) when clicking.
so i've added onclick="selectPic(this.id)" and it calls this function:

function selectPic(id){
var length=document.images.length;

for (var i=0;i<length;i++){
document.images[i].style.border='black solid 1px';
document.getElementById(id).style.border='red solid 3px';

now , the problem is , it works but sometimes , without any rules.. i get this error message "'document.images[...].style' is null or not an object"
and the thumbnail disappear!

i'm using ie 6 and i'm using AJAX to show the thumbnails.


10-30-2006, 10:58 PM
um, just a guess, but try redefining the image file when calling onClick, makes sense to me at least