title: Using PHP and Javascript in onblur function
body: <p>so I have this form:</p>
  
  <pre><code>&lt;form enctype="multipart/form-data" action="cgi-bin/upload.cgi?upload_id=" method="post" onSubmit="return StartUpload(this);" target="xupload"&gt;
  &lt;table&gt;
      &lt;tr&gt;
          &lt;td class="first"&gt;&lt;span class="right"&gt;Upload File: &lt;/span&gt;&lt;/td&gt;
          &lt;td class="second"&gt;&lt;input name="file_1" type="file" onChange="checkExt(this.value)" accept=".mp4, .avi, .wmv, .mov, .camrec, .flv, .zip, .rar"&gt;&lt;/td&gt;
          &lt;td class="third"&gt;&lt;span class="left"&gt;(required)&lt;/span&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;center&gt;&lt;h2&gt;Video Information&lt;/h2&gt;&lt;/center&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="first"&gt;&lt;span class="right"&gt;Your Name: &lt;/span&gt;&lt;/td&gt;
          &lt;td class="second"&gt;&lt;input type="text" name="name"&gt;&lt;/td&gt;
          &lt;td class="third"&gt;&lt;span class="left"&gt;(preferred)&lt;/span&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="first"&gt;&lt;span class="right"&gt;Series ID: &lt;/span&gt;&lt;/td&gt;
          &lt;td class="second"&gt;&lt;input id="series_id" type="text" name="series_id" placeholder="You should have been given this by your admin"&gt;&lt;/td&gt;
          &lt;td class="third"&gt;&lt;span class="left"&gt;(preferred)&lt;/span&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="first"&gt;&lt;/td&gt;
          &lt;td class="second"&gt;&lt;span id="series_id_check"&gt;Enter You're series ID Above and this will change&lt;/span&gt;&lt;/td&gt;
          &lt;td class="third"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="first"&gt;&lt;span class="right"&gt;Title: &lt;/span&gt;&lt;/td&gt;
          &lt;td class="second"&gt;&lt;input type="text" name="title"&gt;&lt;/td&gt;
          &lt;td class="third"&gt;&lt;span class="left"&gt;(preferred)&lt;/span&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="first"&gt;&lt;/td&gt;
          &lt;td class="second center"&gt;&lt;small&gt;Please use "&lt;span style="color:#9c0000"&gt;&amp;lt;br&amp;gt;&lt;/span&gt;" to make a new line&lt;/small&gt;&lt;/td&gt;
          &lt;td class="third"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="first"&gt;&lt;span class="right"&gt;Description: &lt;/span&gt;&lt;/td&gt;
          &lt;td class="second"&gt;&lt;textarea name="desc"&gt;&lt;/textarea&gt;&lt;/td&gt;
          &lt;td class="third"&gt;&lt;span class="left"&gt;(preferred)&lt;/span&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="first"&gt;&lt;span class="right"&gt;Guests: &lt;/span&gt;&lt;/td&gt;
          &lt;td class="second"&gt;&lt;input type="text" name="guests"&gt;&lt;/td&gt;
          &lt;td class="third"&gt;&lt;span class="left"&gt;(optional)&lt;/span&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="first"&gt;&lt;span class="right"&gt;Additional Tags: &lt;/span&gt;&lt;/td&gt;
          &lt;td class="second"&gt;&lt;input type="text" name="tags"&gt;&lt;/td&gt;
          &lt;td class="third"&gt;&lt;span class="left"&gt;(comma separated - optional)&lt;/span&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;input type="submit" name="submit" value="Upload File"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Which I use to upload videos to my web hosting server. I want to be able to change the text in the <code>series_id_check</code> span with some javascript that uses PHP arrays... Here's the PHP that I use for populating the arrays from mysql (I KNOW THAT ITS DEPRECIATED BUT FOR MY WEB HOSTING PHP 5.3 IS INSTALLED AND ITS ONLY DEPRECIATED FROM 5.4):</p>
  
  <pre><code>$sql1 = mysql_fetch_assoc(mysql_query("SELECT COUNT cnt FROM series"));
  $count = $sql1['cnt'];
  
  $gamearray = array($count - 1);
  $namearray = array($count - 1);
  $idarray = array($count - 1);
  
  for ($i = 0; $i &lt; $count; $i++)
  {
      $sql2 = mysql_fetch_assoc(mysql_query("SELECT id,game,name FROM series WHERE id='{$i}'"));
  
      $gamearray[$i] = $sql2['game'];
      $namearray[$i] = $sql2['name'];
      $idarray[$i]   = $sql2['id'];
  }
  </code></pre>
  
  <p>I know it connects to the database fine as I've got a <code>die</code> statement when it tries to connect</p>
  
  <p>The javascript is:</p>
  
  <pre><code>var id = "series_id";
  
  document.getElementById("series_id").onblur = function()
  {
      var value = document.getElementById(id).value;
  
  
      var gameArray = new Array(&lt;? echo implode(',', $gamearray); ?&gt;;
      var nameArray = new Array(&lt;? echo implode(',', $namearray); ?&gt;;
      var idArray = new Array(&lt;? echo implode(',', $idarray); ?&gt;;
  
      if (inArray(value,idArray)
      {
          var id = parceInt(value);
          var game = gameArray.indexOf(id);
          var name = nameArray.indexOf(id);
          var input= "You've inputted the id for the game: " + game + " for the series: " + name;
  
          document.getElementById("spawn_series_id_check").innerHTML = input;
      }
  });
  
  function inArray(var input, var array)
  {
      var count = array.length;
      var returnVal = false;
  
      for (var i = 0; i &lt; count; i++)
      {
          if (array[i] == input)
          {
              returnVal = true;
          }
      }
  
      return returnVal;
  }
  </code></pre>
  
  <p>Basically the text in the series_id_check doesn't change. Could you tell me how to fix it</p>