title: How to set a value to a hidden type input from javascript
body: <p>I am working with jsp. I want to set a value from JavaScript to HTML hidden type input in order to pass the value to another page.</p>
  
  <p>This is my HTML code:</p>
  
  <pre><code>&lt;form id="reg" method="post" action="/questionnaire.jsp"&gt;
      &lt;input type="hidden" name="userId" value="123"&gt; 
      &lt;button id="submit" name="sr-buttobmitun"&gt;Submit&lt;/button&gt;
  &lt;/form&gt; 
  </code></pre>
  
  <p>JavaScript is like:</p>
  
  <pre><code>&lt;script&gt;
      var userId = "123";
  &lt;/script&gt;
  </code></pre>