title: Hidden input value set by JQuery not passed on form submit
body: <p>I am using Codeigniter and I have a form with a button group (2 buttons). On new page load (initial visit to site) the first button is selected and my script sets the value of a hidden input that is associated with this button. If the user selects the second button, additional fields are shown on the screen and the hidden input value for this button is set while the first hidden input value is cleared. This all works fine.</p>
  
  <p>I can see in firebug that the hidden input value is being updated but when I submit my form, the hidden input has no value.</p>
  
  <p><strong>HTML</strong></p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div class="panel-heading" id="order-hd"&gt;
    &lt;div class="btn-group" role="group" aria-label="..."&gt;
      &lt;button type="button" id="single-ship" class="btn btn-primary"&gt;
        &lt;i class="fa fa-user" aria-hidden="true"&gt;&lt;/i&gt; Place order for a single recipient
      &lt;/button&gt;
      &lt;button type="button" id="multi-ship" class="btn btn-primary"&gt;
        &lt;i class="fa fa-users" aria-hidden="true"&gt;&lt;/i&gt; Place an order for multiple recipients
      &lt;/button&gt;
    &lt;/div&gt;
    &lt;input type="hidden" name="single_ship" id="single_ship" value="" /&gt;
    &lt;input type="hidden" name="multi_ship" id="multi_ship" value="" /&gt;
  &lt;/div&gt;
  </code></pre>
  
  
  
  <p><strong>PHP</strong></p>
  
  <pre><code>if($this-&gt;input-&gt;post('multi_ship')) {
    $this-&gt;form_validation-&gt;set_rules('fname', 'First Name', 'trim|required');
    $this-&gt;form_validation-&gt;set_rules('lname', 'Last Name', 'trim|required');
    $this-&gt;form_validation-&gt;set_rules('address', 'Address', 'trim|required');
    $this-&gt;form_validation-&gt;set_rules('city', 'City', 'trim|required');
    $this-&gt;form_validation-&gt;set_rules('state', 'State', 'trim|required');
    $this-&gt;form_validation-&gt;set_rules('zip', 'Zip Code', 'trim|required');
    $order_type = 'M';
  }
  else {
    $order_type = 'S';
  }
  </code></pre>
  
  <p><strong>Script</strong></p>
  
  <pre class="lang-js prettyprint-override"><code>$(document).ready(function() {
  
    if (!$('#multi-ship').hasClass("locked") &amp;&amp; !$('#single-ship').hasClass("locked")) {
      //Default sinlge ship method on initial page load
      $('#shipping-addr').hide();
      $('#single-ship').addClass('locked');
      $('#single-ship').attr('disabled', 'true');
      $('#single_ship').val('X');
    }
  
    $('#multi-ship').on('click', function() {
      $('#shipping-addr').show();
      $('#single-ship').removeClass('locked');
      $('#single-ship').removeAttr('disabled');
  
      $('#multi-ship').addClass('locked');
      $('#multi-ship').attr('disabled', 'true');
  
      $('#single_ship').val('');
      $('#multi_ship').val('X');
    });
  
    $('#single-ship').on('click', function() {
      $('#shipping-addr').hide();
      $('#multi-ship').removeClass('locked');
      $('#multi-ship').removeAttr('disabled');
  
      $('#single-ship').addClass('locked');
      $('#single-ship').attr('disabled', 'true');
  
      $('#multi_ship').val('');
      $('#single_ship').val('X');
    });
  
    $('#giftwrap').change(function() {
      cb = $(this);
  
      cb.val(cb.prop('checked'));
    });
  
    $("#item_delete").click(function(e) {
      e.preventDefault();
      $('#cartform').submit();
    });
  });
  </code></pre>
  
  
  
  <p><a href="https://i.stack.imgur.com/DSF8t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DSF8t.png" alt="enter image description here"></a></p>