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

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Nathaniel
Forum Contributor
Posts: 396
Joined: Wed Aug 31, 2005 5:58 pm
Location: Arkansas, USA

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

Post 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]
Last edited by Nathaniel on Tue Jul 04, 2006 7:22 am, edited 1 time in total.
User avatar
Nathaniel
Forum Contributor
Posts: 396
Joined: Wed Aug 31, 2005 5:58 pm
Location: Arkansas, USA

Post by Nathaniel »

Ok, well, tip of the day: get sleep
Post Reply