Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting onclick property

Status
Not open for further replies.

drkestrel

MIS
Sep 25, 2000
439
GB
I am trying to dynamically change the onClick evenHandler using:
Code:
var sNoteOnClickJs = 'showDetails()';  //showDetails is a JavaScript function defined in the same HTML page.

objImg.onclick =sNoteOnClickJs;  //objImg  is a <img> tag in a <td>


I did an alert for objImg.parentElement.parentElement.outerHTML it looks
exactly the same as a static working version., but the onClick event is not firing off! Why?

am i no allowed to set onClick??

btw, doing the following has the same effect

Code:
objImg.setAttribute('onclick',sNoteOnClickJs);

Btw, this is happening on IE6 SP1
 
Hi,

May not have enough info here to fix but try removing quotes and ()

var sNoteOnClickJs = 'showDetails()';
This means sNoteOnClickJs is a string, try :
var sNoteOnClickJs = showDetails;

If this doesn't work cam you post more.

Kev
[afro2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top