title: Append value to input field using jQuery
body: <p>I have a small form with three fields and I can submit that form choose different options next time. I am submitting this form with ajax call. </p>
  
  <p>Now on form submit I want to post all the selected options. For this, I have created a hidden field like </p>
  
  <pre><code>&lt;input type="hidden" name="selectedproduct[]" id="sel-product"&gt;
  </code></pre>
  
  <p>and ajax success method am appending value like</p>
  
  <pre><code> $('#sel-product').val(element.product);
  </code></pre>
  
  <p>But here I am getting only one value instead of an array. How can I append all the values to the field?</p>