0

I have an array of youtube videoIDs. The script selects a random videoID. I need to echo this value in the same script. The script without that random variable works now with

videoId: 'NmhLuCSyBJg'

i need

alert(chosen_vid) 
videoId: 'document.write(chosen_vid)'

alert works, but, document.write does not suit here, need some kind of "echo"

the original script is How do I automatically play a Youtube video (IFrame API) muted?

SOLVED! videoId: ' HERE I HAVE PUT THE WAY, I WAS GETTING THE VARIABLE VALUE'

Community
  • 1
  • 1
Ivan
  • 385
  • 3
  • 5
  • 14
  • `document.write` makes me cry. Where do you want the output? `document.body.appendChild(document.createTextNode(chosen_vid));` or `console.log(chosen_vid);` .. Also, why are you using labels? – Paul S. Jun 07 '13 at 19:12
  • It sounds like you just want to use a variable. – SLaks Jun 07 '13 at 19:13
  • Yes, i want to use a variable in the same script. alert(chosen_vid) - works videoId: '(chosen_vid)' - i want it here – Ivan Jun 07 '13 at 19:14
  • Then just use the variable. – SLaks Jun 07 '13 at 20:11
  • SLaks, i can use the variable with alert. How do i change the line 185, that is wrong http://pastebin.com/t28rzclk – Ivan Jun 07 '13 at 20:35

1 Answers1

0

You sound like you want... document.getELementById('SOMEID').innerHTML = chosen_vid;

rjg132234
  • 590
  • 3
  • 8
  • 21
  • `innerHTML` is not a function – SLaks Jun 07 '13 at 19:13
  • the HTML is put together by another script, that needs my variable chosen_vid, see the original http://stackoverflow.com/questions/8869372/how-do-i-automatically-play-a-youtube-video-iframe-api-muted . I just want to play random vid from my array muted... – Ivan Jun 07 '13 at 19:20