...

View Full Version : $(currentID).onclick = ERRORZ



limpsharp
07-02-2006, 11:01 AM
Last post i promise.

$(currentID).onclick = "grow('+currentID+','+oheight+','+theight+','+twidth+','+margin+')";
Doesn't provide any errors - but neither does it work.

I need to put these variables into the onclick function.

i can use

$(currentID).onclick = grow;but this does not allow me to assign variables.

PS. $ is shorthand for document.getElementByID as found in prototype framework.

limpsharp
07-02-2006, 11:09 AM
it seems that even the line

$(currentID).onclick = alert('chump');
doesn't work - instead of alerting onclick, it alerts as soon as the script arrives at that point and gives the error:-

Error: Not Implemented

limpsharp
07-02-2006, 11:10 AM
this is the function in full


function shorten(){
if(height>oheight){
height = height - 4;
margin = margin + 2;
$(currentID).style.height = height+"px";
$(currentID).style.marginTop = margin+"px";
growtimer[currentID] = setTimeout(function(){ shorten(); },1);
}else{
lock = false;
$(currentID).onclick = alert('chump');
}
}

limpsharp
07-02-2006, 11:25 AM
$(currentID).onclick = function(){ grow(currentID,oheight,theight,twidth,margin); }

FIXED

Although this was a guess, if anyone wants to explain to me why this works then feel free :)

_Aerospace_Eng_
07-02-2006, 10:20 PM
Browsers like using setAttribute however IE doesn't like it when you are trying to set an event handler using setAttribute so you must use an anonymous function like you have done in your last post.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum