Django: How do I get multiple values from checkboxes in dataTable
<p>In HTML, every form field needs a name attribute in order to be submitted to the server. But I used dataTable to display all data and pagination. The list checkbox just get the data of the current page not get data of next page or previous page. How can I get all the values of checkbox?</p>

<p>in the template</p>

<pre><code>&lt;input type="checkbox" name="orderId" value="{{ order_id }}" checked&gt;
</code></pre>

<p>and in the view:</p>

<pre><code>order_list = request.POST.getlist('orderId') 
</code></pre>

<p>You can use a hidden input field(type hidden) containing the string (comma separated value), which can later be received on server side as string and further it's splited using split method which will result in desired list</p>

<pre><code>   &lt;form&gt; 
      &lt;input id="result" type="hidden" name="result"&gt; 
      &lt;!--your data table goes here--&gt; 
   &lt;/form&gt; 

  &lt;script&gt; 
  $(document).ready(function(){ 
     var resultarray=[]; 
     $('form input:checkbox').on('change', function(){ 

      var orderValue=$(this).val();

     // if string already available then remove(uncheck operation) 
     if(resultarray.indexOf(orderValue)!=-1) 
     { 
        resultarray.splice(resultarray.indexOf(orderValue), 1);
      } 
     else 
     { 
      //if sting is not available then add(check operation) 
      resultarray.push(orderValue);
     } 

   var text=""; 
   for(x in resultarray) 
   { 
     text+=x+",";
     //you may add an extra condition for not adding comma at last element
   }
   $("#result").val(text);
  }); 
}); 
</code></pre>

<p></p>

python django python-3.x