I need to retreive a page item number without looping so I can reference it. I currently have code set up like this, but it can take upwards of 45 seconds to process if there are a lot of items on the page:
function CalClick(theObject){
for(var i=0;i<99999;i++)
if(theObject==document.all.item(i))
return i;
return -1;
}
<img src="some.gif" onClick="alert(CalClick(this));">
Is there a way I can pass the object item number straight from the item?
I would specify the item name (<img src="some.gif" name="a" onClick="alert(CalClick('a'));">), or hard code the number in the object (<img src="some.gif" onClick="alert(CalClick(12));">), but I am relying on repeating/copying this onClick code throughout the page and need it to automatically know what item is was referenced/clicked from.
Cheers,
C.
function CalClick(theObject){
for(var i=0;i<99999;i++)
if(theObject==document.all.item(i))
return i;
return -1;
}
<img src="some.gif" onClick="alert(CalClick(this));">
Is there a way I can pass the object item number straight from the item?
I would specify the item name (<img src="some.gif" name="a" onClick="alert(CalClick('a'));">), or hard code the number in the object (<img src="some.gif" onClick="alert(CalClick(12));">), but I am relying on repeating/copying this onClick code throughout the page and need it to automatically know what item is was referenced/clicked from.
Cheers,
C.