views:

2165

answers:

2

I am trying to insert a variable passed to my function into the output of my .innerHTML = code but do not know how to properly insert it into the HTML output.

function playsong(song)
{
    parent.document.getElementById('player').innerHTML = '<object width="199" height="26"><param name="movie" value="audio_player_black.swf"><embed src="audio_player_black.swf?audio_file=upload/'[song]'&color=00000" width="199" height="26"></embed></object>';
}

I just get [song] in my HTML output rather than the value of [song]

Not sure how I need to do this properly

+3  A: 

Instead of:

[song]

use:

 +song+
Diodeus
You'll need to terminate the string beforehand and then reopen it afterward, too.
Chuck
+4  A: 

easy:

parent.document.getElementById('player').innerHTML = '<object width="199" height="26"><param name="movie" value="audio_player_black.swf"><embed src="audio_player_black.swf?audio_file=upload/'+song+'&color=00`000" width="199" height="26"></embed></object>';

just like concatenating any 2 + strings

mkoryak
Thanks so much.
ian