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

07-02-2006, 12:01 PM
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, 12:09 PM
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, 12:10 PM
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, 12:25 PM
$(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, 11: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.