title: How to set value for hidden field when a link clicked using javascript
body: <p>I want to set value for hidden field(sub_catid) when a link clicked. My source codes as below.</p>
  
  <p><strong>Hidden Input Field</strong></p>
  
  <pre><code>&lt;input type="hidden" name="sub_catid" value="" id="sub_catid"&gt;
  </code></pre>
  
  <p><strong>a link</strong> </p>
  
  <pre><code>&lt;a href="#" data-subcat="3" class="sub-cat-id"&gt;Sub Category Name&lt;/a&gt;
  </code></pre>