title: Checkbox with Jquery map function?
body: <p>I have the following code,</p>
  
  <pre><code>...
  
  &lt;input type="hidden" name="unchecked"  id="unchecked" value="" /&gt;
  &lt;?php
      $ind = 1;
      foreach($array as $v){
  ?&gt;
  
  &lt;input class="checkbox checked" id="checked_&lt;?php echo $ind; ?&gt;" type="checkbox" value="&lt;?php echo $value['id']; ?&gt;"/&gt;
  
  &lt;?php
      $ind++;
      }
  ?&gt;
  
  ...
  </code></pre>
  
  <p>I want to store checkbox values as comma seperated in hidden box. so i tried with the following  jquery ,</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(function(){    
          $("input.checked").click(function(){  
              //alert($(this).val());
              $("input#unchecked").val($.map($("input[id^='checked_']"), function( item ) {
                  return $(item).val();
              }).join(",")); 
          });
      });  
  &lt;/script&gt;
  </code></pre>
  
  <p>The above script stores all values of checkbox when i click any one of check box. what i done wrong on this. kindly advice</p>