title: Dynamically substituting checkboxes with hidden fields using jQuery
body: <p>Since checkboxes do send their content only when they are checked but my server side script needs ala of them (checked and unchecked fields with values 'Y' or 'N'), I need to dynamically substitute checkbox form fields (their functionalities) with hidden input fields with the same names. So I need jQuery script which will do the following;</p>
  
  <ul>
  <li>for each checkbox input field on my page it should dynamically insert hidden input field with the same name as checkbox</li>
  <li>it should add onclick listener to all checkbox fields which would set previous hidden field to 'Y' when checkbox is checked, and 'N' otherwise</li>
  <li>remove name of checkbox input field in order to avoid naming conflict when sending form content to server (not sure if this is really needed)</li>
  </ul>
  
  <p>so jQuery should current state:</p>
  
  <pre><code>&lt;input type="checkbox" name="name1" checked="checked" /&gt;
  &lt;input type="checkbox" name="name2" /&gt;
  </code></pre>
  
  <p>dynamically substitute with:</p>
  
  <pre><code>&lt;input type="hidden" name="name1" value="Y" /&gt;
  &lt;input type="checkbox" checked="checked" onclick="function()"/&gt;
  &lt;input type="hidden" name="name2" value="N" /&gt;
  &lt;input type="checkbox" onclick="function()"/&gt;
  </code></pre>
  
  <p>or replace checkbox fields with hidden fields with corresponding values before submitting form.</p>
  
  <p>function() could be noname and dynamically assigned to checkboxes and change previous hidden fields with 'Y' or 'N' according to checkbox state.</p>