title: Change form input value with javascript
body: <p>I am trying to change the input value of a hidden form to update the score of a game in my database.</p>
  
  <p>I have this form code on a php page that displays and plays the game.</p>
  
  <pre><code>&lt;form id ="recordForm" method="POST" action="updatePHP.php"&gt;
          &lt;input type='hidden' name="record" id='record' value='' /&gt;
   &lt;/form&gt;
  </code></pre>
  
  <p>And am trying to change the value of the hidden input field with this javascript.  This is in the separate javascript file that is controlling the game.</p>
  
  <pre><code>function postPHP(newRecord){
  alert("POST TO PHP");  //test to make sure I am calling this function
  alert (newRecord);  //alerts the correct value
  
  var elem = document.getElementById('record');
  elem.value = 12;
  //    document.getElementById('record').value = newRecord;
  //    document.getElementById('recordForm').submit();
  };
  </code></pre>
  
  <p>There are a lot of topics on this subject but I am just not able to figure out what I am doing wrong. Any suggestions?</p>