Re-write an onclick javascript function

This had me baffled for a few hours.  I needed to re-write a javascript function in a onclick event using the contents of a variable rather than just a variable.

The problem was whilst trying to do this it kept placing the variable in there and not the contents of the variable.

Turned out rather simple in the end.  Hope it of use to someone.

document.getElementById('catlink').onclick=new Function
("opencat("+catid+",'"+newstate+"',"+image+","+level+");");
This entry was posted in javascript and tagged . Bookmark the permalink.

Leave a Reply