title: Get $_POST data from form elements with class attribute rather than id
body: <p>Given that the user can use javascript to include an undefined amount of <em>sorts</em> how can I get the     $_POST data from all the <em>select</em>s on the page since $_POST expects ids rather than classes? </p>
  
  <p><strong>html file - include_sorts.php</strong></p>
  
  <pre><code>&lt;div class="sorts"&gt;
      &lt;select class="departments"&gt;
          &lt;option value="1"&gt;Finance&lt;/option&gt;
          &lt;option value="2"&gt;Sales&lt;/option&gt;
      &lt;/select&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>php file - home.php</strong></p>
  
  <pre><code>&lt;?php
       $departments = $_POST['departments'];
  ?&gt;
  
  &lt;html&gt;
      &lt;head&gt;&lt;/head&gt;
      &lt;body&gt;
          &lt;form action="home.php" method="post"&gt;
              &lt;?php
               for($i = 0; $i &lt; 4; $i++)
               {
                   include("include_sorts.php");
               }
              ?&gt;
          &lt;button type="submit"&gt;Submit&lt;/button&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>