I realise this and similar questions / answers exist already. But I've looked at a lot now and just not sure what simple thing I'm doing wrong. I'm just getting to grips with this. I have the error "Can't find variable: getElementById" I've try changing the order of the script and HTML. I used this random method which works fine Get random item from JavaScript array Its just applying it to the src...
This video was also helpful https://www.youtube.com/watch?v=pqLS4oyJ8cA
Here is my code: http://jsfiddle.net/udkhpytm/
<div>
<script id="IntroAnimation" type="text/javascript" charset="utf-8" src=""></script>
</div>
<script type="text/javascript">
var my_array = ['FILE1', 'FILE2', 'FILE3'];
var ri = Math.floor(Math.random() * my_array.length); // Random Index position in the array
getElementById("IntroAnimation").src = ri;
</script>
I'm trying to get a random item from the array and place it in the src of my Script by the scripts ID.