title: Setting value of hidden element in php
body: <p>I have a hidden field in form. On form submit I call a database function to add the inputs to database and return result of query. I wish to set the value returned to hidden field. But when I am not able to assign a value to it</p>
  
  <pre><code>&lt;form name="frmAddBook" id="frmAddBook" method="post"&gt;
  &lt;input type="hidden" name="actionResult" id="actionResult"&gt;
  </code></pre>
  
  <h2>PHP</h2>
  
  <pre><code>echo '
  &lt;script type="text/javascript"&gt;
  alert("hello"); 
  document.getElementById("actionResult").value=1;
  alert("2222222");
  alert(document.frmAddBook.getElementById("actionResult").value);
  &lt;/script&gt;';
  </code></pre>