views:

17

answers:

2

Help please

I am very new to this so please be kind and type very slow so I can understand....

how do I dynamically change an onclick event to a new function here is the example

<img name="space1" id="space1" src="images/8001.jpg" height="150 px" onclick="lrgWithInfo('1')" />

here is what isnt working all I want to change is the value passed.

document.getElementById("space1").onclick = lrgWithInfo('13');

Thanks for your help

kim

A: 
document.getElementById("space1").onclick = lrgWithInfo('13');

This assigns the output of lrgWithInfo('13'); to you on click function. You could try

document.getElementById("space1").onclick = function () { lrgWithInfo('13'); };
Johan
A: 

Hi Johan,

Thank-you so very much for your help!!

It worked, and although I tried using a new function I may not have added the semi colan inside the brackets. I never would have noticed that on my own.

Thanks again, project worked, and I will be back with a million more questions.

You rock!

kim

kim

related questions