title: Hidden input has value before submit set in Javascript; once submitted it is null on the backend
body: <p>I have a Play application which has a hidden input field that has a value set via Javascript before the form is submitted.  The field is set correctly on open and before and after the submit process.  However, when it gets to the controller, it is set to <code>null</code>.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function(){
     console.log("ptp.load value = " + 
  $('input[name="remedy_Institutional_Costs"]').val());
  });
  
  $("#cancelButtonBottom").click(function () {
  $("#ptp").submit();
  console.log("ptp.submit AFTER - final value = " + $('input[name="remedy_Institutional_Costs"]').val());
  });
  
  $("#ptp").submit(function (event) {
  $('input[name="remedy_Institutional_Costs"]').val("No");
  console.log("ptp.submit BEFORE - final value = " + $('input[name="remedy_Institutional_Costs"]').val());
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;input type="hidden" name="remedy_Institutional_Costs" value="@adultInstitution.getRemedy_Institutional_Costs()" /&gt;
  &lt;button type="button" id="cancelButtonBottom"&gt;Exit&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>When the form loads, the value is "No":
  <a href="https://i.stack.imgur.com/LH2YC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LH2YC.png" alt="enter image description here"></a></p>
  
  <p>When I click the <code>Exit</code> button, the value is still set to "No":
  <a href="https://i.stack.imgur.com/HCAKz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HCAKz.png" alt="enter image description here"></a></p>
  
  <p>However, when it makes it back to the controller, the value is set to null:
  <a href="https://i.stack.imgur.com/v701t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v701t.png" alt="enter image description here"></a></p>
  
  <p>I found a few posts, but they didn't help me out:</p>
  
  <p><a href="https://stackoverflow.com/questions/40519081/check-hidden-form-input-has-value-on-form-submit">Check Hidden Form Input has Value on Form Submit</a></p>
  
  <p><a href="https://stackoverflow.com/questions/10666752/changing-value-of-hidden-input-fields-depending-on-submit-button">changing value of hidden input fields depending on submit button</a></p>
  
  <p>I appreciate the help.</p>