title: Move existing div into another div with Javascript
body: <p>After selecting an option from first dropdown list then another dropdown list appear according to selected option. When an option is selected from the second one then the selected one's value is sent to <strong>input element</strong> that is at the top of the page as hidden. It also calls function "bolumGonder" which submits form that includes <strong>input element</strong> to same page with GET method. Then according to GET variable retrieve some data from database.
  PHP</p>
  
  <pre><code>&lt;?php
  session_start();
  if (isset($_GET['bolumtani']) &amp;&amp; !empty($_GET['bolumtani'])) {
      include_once 'alinabilendersler.php';
  }   
  ?&gt;
  
  HTML
  
  &lt;script&gt;    
      function bolumGonder() {
          var seciliBolum = $(".insaat").val();
          if ( seciliBolum.length &gt; 0 ) {
              $("#bolumtani").val(seciliBolum);
              document.bolumtaniform.submit();
          }       
      }
  &lt;/script&gt;
  &lt;form name="bolumtaniform" action="program.php" method="GET"&gt;   
      &lt;input name="bolumtani" id="bolumtani" type="text" style="display:none" /&gt;
  &lt;/form&gt;
  
  &lt;div id="orta_div"&gt;
      &lt;select class="fakulte_sec" onclick = "bolumAc()"&gt;
          &lt;option selected&gt;Fakülte&lt;/option&gt;
          &lt;option value="insaat"&gt;İnşaat Fakültesi&lt;/option&gt;
          &lt;option value="mimarlik"&gt;Mimarlık Fakültesi&lt;/option&gt;
          &lt;option&gt;Makina Fakültesi&lt;/option&gt;
          &lt;option&gt;Uçak ve Uzay Bilimleri Fakültesi&lt;/option&gt;
      &lt;/select&gt;
  
      &lt;select class="insaat" style="display:none" onchange="bolumGonder()"&gt;
          &lt;option value="" selected&gt;Bölüm&lt;/option&gt;
          &lt;option value="ins"&gt;İnşaat Mühendisliği %30&lt;/option&gt;
          &lt;option value="inse"&gt;İnşaat Mühendisliği %100&lt;/option&gt;
          &lt;option&gt;Çevre Mühendisliği %30&lt;/option&gt;
          &lt;option&gt;Çevre Mühendisliği %100&lt;/option&gt;
      &lt;/select&gt;
  
      &lt;select class="mimarlik" style="display:none"&gt;
          &lt;option&gt;Mimarlık %30&lt;/option&gt;
          &lt;option&gt;İnşaat Mühendisliği %100&lt;/option&gt;
          &lt;option&gt;Çevre Mühendisliği %30&lt;/option&gt;
          &lt;option&gt;Çevre Mühendisliği %100&lt;/option&gt;
      &lt;/select&gt;
      &lt;div class="uygun_dersler_ana_div" style="width:100%; color: white; height: 1500px;position: absolute ;overflow: hidden"&gt;&lt;?php if (isset($_GET['bolumtani']) &amp;&amp; !empty($_GET['bolumtani'])) {$sonuc = bolum($_GET['bolumtani']);} else {}?&gt;&lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>Gettin data from MySQL</p>
  
  <pre><code>&lt;?php
  ##Database Bağlantısı##
  $host = 'host';
  $user = 'username';
  $pass = 'password';
  $db = 'databasename';
  
  $baglan = mysql_connect($host, $user, $pass);
  mysql_select_db($db);
  
  mysql_query("SET NAMES 'utf8'  ");
  mysql_query("SET CHARACTER SET utf8");
  mysql_query("SET COLLATION_CONNECTION = 'utf8_turkish_ci' ");
  
  
  ## Her Ders İçin Ayrı Tablo Oluştur ##            
  
  function bolum($degisken) {
      # Ders Kodlarını Al # # Gets Class Name From Another Website, Asign them into an array ##
      $ch = curl_init("someURL");
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      $cl = curl_exec($ch);
      $dom = new DOMDocument();
      @$dom-&gt;loadHTML($cl);
      $xpath = new DOMXpath($dom);
  
      $derskodlari = $xpath-&gt;query("//option[position() &gt;1]");
      $todbderskodlariarr = array();
      foreach ($derskodlari as $derskodu) {
          $todbderskodlariarr[] = $derskodu;
      }
  
      $todbderskodu = array();
  
      foreach ($todbderskodlariarr as $todbderskoduarr) {
          $todbderskodu[] = $todbderskoduarr-&gt;nodeValue;
      }
  
      ## This is just an exception. ##
      $todbderskodu[81] = "MODD";
  
      for ($a = 0; $a &lt; count($todbderskodu); $a++) {
          @$todbderskodu[$a] = mysql_query("SELECt crnler, derskodu, gun, bina, dersadi FROM $todbderskodu[$a] WHERE dersialabilen LIKE '%" . $bolum . "%'");
      }
  
      $a = 0;
      while ($a &lt; count($todbderskodu)) {
          while ($row = mysql_fetch_array($todbderskodu[$a], MYSQL_NUM)) {
              $class = substr($row[1], 0, 3);
              echo '&lt;div class="' . $class . '" id="' . $row[0] . '"&gt;' . $row[4] . $row[0] . '&amp;nbsp; |' . $row[2] . '&lt;/div&gt;';
          }
          echo '&lt;br&gt;';
          $a = $a + 1;
      }
  }
  ?&gt;
  </code></pre>
  
  <p>Upto now everything works perfect. Script creates divs that have class AKM,ALM,ATA,UCK.. etc.  I want to put all divs that have same class into classname_main_div. How can i do that?</p>