Page 1 of 1

[SOLVED]: innerHTML'ing a string with function(object) call?

Posted: Mon Jul 03, 2006 10:25 pm
by Nathaniel
Hi guys,

I have an object that needs to be placed inside a function call on an onclick event, and javascript has to make this all up itself.
Like so:

Code: Select all

document.getElementById('list').innerHTML += '<li><span onclick="aFunction(' + object + ');">La la la.</span></li>';
Surely there's a way to do that? Passing an Id to the object would require, as far as I can see, building a whole Library class system, because the object is stored inside a multidimensional array.

Right now, when trying the code I posted, I get a "missing a ] after element list." error.

- Nathaniel[/syntax]

Posted: Tue Jul 04, 2006 7:22 am
by Nathaniel
Ok, well, tip of the day: get sleep