title: How to set the value of a input hidden field through JavaScript?
body: <p>I am trying to call the <code>resetyear</code> function and it's getting called also, but the flow stops at <code>alert(&quot;over&quot;)</code>. It doesn't transfer its control to <code>resetmaster</code>.</p>
  <pre><code>    String flag = &quot;&quot;;
      flag = (String) session.getAttribute(&quot;flag&quot;);
      System.out.println(&quot;flag = &quot; + flag);
      if (flag == null) {
          flag = &quot;&quot;;
      }
      if (flag.equals(&quot;yes&quot;)) {
  %&gt;   
  &lt;script&gt;
     
     alert(1);
    // resetyear();
      dontreset();
      //document.getElementById(&quot;checkyear&quot;).value = &quot;1&quot;;
      //alert(document.getElementById(&quot;checkyear&quot;).value);
      
  &lt;/script&gt;
  &lt;%} else if(flag.equals(&quot;no&quot;))
      {%&gt;
  &lt;script&gt;
      alert(2);
      //document.getElementById(&quot;checkyear&quot;).value = &quot;2&quot;;
      //alert(document.getElementById(&quot;checkyear&quot;).value);
      resetyear();
  &lt;/script&gt;
  &lt;%}else{}%&gt;
  
  
  function resetyear(){
  
  if(confirm(&quot;DO YOU WANT TO RESET THE YEAR?&quot;))
  {
      alert(&quot;hello&quot;);
      //document.forms['indexform'].action = &quot;resetmaster&quot;;
      //alert(document.forms['indexform'].action);
      //document.forms['indexform'].submit();  
      alert(&quot;over&quot;);
      form.action = &quot;resetmaster&quot;;
      form.submit();
      alert(1);
  }
  </code></pre>