title: Reading checkboxes values with jQuery
body: <p>I have a little bit problem  with reading datas from checkboxes.</p>
  
  <pre><code> {foreach value=artist2 from=$artist}
                  &lt;br /&gt;
  
                     &lt;input type="checkbox" name="artist[]" value="{$artist2.MOVIE_ID}-{$artist2.PERSON_ID}" { in_array array=$item match=$artist2.NAME_SURNAME returnvalue="CHECKED" }&gt;{$artist2.NAME_SURNAME}&lt;br /&gt;
  
                  &lt;hr /&gt;
                  {/foreach}
                     &lt;p align="right"&gt;  &lt;a style="float: right" href='javascript:void(null);' onclick="deleteData();" &gt;&lt;input type="submit" name="removeArtistFromMovie" onclick="showMessage('Seçilen oyuncu(lar) başarıyla silindi')" value="Seçilenleri Sil" id="value"&lt;/p&gt;&lt;/a&gt;
                  &lt;br &gt;
                    &lt;/form&gt;
  </code></pre>
  
  <p>I produce checkboxes like that and in my js file:</p>
  
  <p>I try this</p>
  
  <pre><code>function deleteData(){
      var artistIds = new Array();
  
      $("input[@type=artist[]][@checked]").each(function(){
          artistIds.push($(this).attr('id'));
      });
  
  alert(artistIds);
  
  
  
  $.post('/management/deleteDataAjax2', 
         { json: JSON.stringify({'artistIds': artistIds}) },
         function(response){
          alert("Başarıyla silindi");
          window.location.replace(window.location.pathname);
  });
  
  
  
  }
  </code></pre>
  
  <p>However, above code does not take the values of checkboxes which is checked. Why ? </p>
  
  <p><strong>Finally</strong></p>
  
  <p>I think problem is here because the page does not go to js.</p>
  
  <pre><code>&lt;form name=form1 method=post action=# onsubmit='return validate(this)'&gt;
  
                  &lt;br /&gt;
  
                     &lt;input type="checkbox" name="artist[]" value="{$artist2.MOVIE_ID}-{$artist2.PERSON_ID}"  /&gt;{$artist2.NAME_SURNAME}&lt;br /&gt;
  
  
                  &lt;hr /&gt;
  
  
  
                  {/foreach}
                  &lt;p align="right"&gt;
                  &lt;a style="float: right" href='javascript:void(null);' onclick="deleteData();" &gt;&lt;br /&gt;
                      &lt;input type="button" name="checkArtistButton" value="Seçilenleri Sil" id="ajaxCheckbox" /&gt;&lt;/a&gt;&lt;/p&gt;
                  &lt;br &gt;
                    &lt;/form&gt;
  </code></pre>
  
  <p>and this is my  js </p>
  
  <pre><code>function deleteData(){
  
      var artistIds = [];
  $('#ajaxCheckbox').click(function() {
      $("input[name='artist[]']:checked").each(function() {
          artistIds.push($(this).attr('value'));
      });
      alert(artistIds);
  });​
  ​    
  
  
  
  $.post('/management/deleteDataAjax2', 
         { json: JSON.stringify({'artistIds': artistIds}) },
         function(response){
          alert("Başarıyla silindi");
          window.location.replace(window.location.pathname);
  });
  
  
  
  }
  </code></pre>