title: Set subtitle track using javascript in html5
body: <p>I am using the video tag and track tag to show a video with a .vtt subtitle file on my website, as in the code below: </p>
  
  <pre><code>&lt;div id="Video"&gt;
  &lt;video id="player" controls width="1024" height="576"&gt;
  &lt;source src="video/video00.mp4" type="video/mp4"/&gt;
  &lt;track id="subtitletrack" label="English" kind="subtitles" srclang="en" src="subtitle/video02.vtt" default&gt;
  &lt;/video&gt;
  </code></pre>
  
  <p></p>
  
  <p>This all works fine, but I would like to set the subtitle randomly from an array using javascript: </p>
  
  <pre><code>var subArray = ["subtitle/video00.vtt","subtitle/video01.vtt","subtitle/video02.vtt"];
  var subtitle = subArray[Math.floor(Math.random()*subArray.length)];
  </code></pre>
  
  <p>Now the variable 'subtitle' is one of three random vtt files. </p>
  
  <p>How can I set the track src to the variable 'subtitle'? </p>
  
  <p>Thank you very much!</p>