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

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.

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

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

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

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


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

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.