title: Get formatted text from div to PHP variable
body: <p>I am trying to extract formatted contents of div element using JS and passing it to a hidden variable.
  So far I have read all questions on stackoverflow regarding this topic, it seems like I have found a solution, it has actually worked once, but all of a sudden it stopped working and I can't find a way of making it work again.</p>
  <p>I look for the easiest solution without AJAX, DOM etc.</p>
  <p>My code:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
  $conn = new PDO('mysql:host=localhost;dbname=parek', 'parek', 'parek');
  $conn-&gt;query("SET NAMES 'utf8'");
  
  if (isset($_POST['aktualita'])) {
  
    $datum = date('d. m. Y');
    $jmeno = $_POST['jmeno'];
    $text = $_POST['text'];
  
    $insert = $conn-&gt;prepare("INSERT INTO aktuality (datum, nazev, text) VALUES ('$datum', '$jmeno', '$text')");
    $insert-&gt;execute();
  
    $message = "Aktualita byla úspěšně zveřejněna";
    echo "&lt;script type='text/javascript'&gt;alert('$message'); window.location.replace('/');&lt;/script&gt;";
  }
  
  
  
  ?&gt; &lt;style&gt;
    button {
      background-color: #e6c63b;
      width: 100%;
      color: white;
      padding: 15px;
      margin: 10px 0px;
      border: none;
      cursor: pointer;
    }
  
    form {
      border: 3px solid #f1f1f1;
    }
  
    input[type=text],
    input[type=password] {
      width: 100%;
      margin: 8px 0;
      padding: 12px 20px;
      display: inline-block;
      border: 2px solid green;
      box-sizing: border-box;
    }
  
    button:hover {
      opacity: 0.9;
    }
  
    .cancelbtn {
      width: auto;
      padding: 10px 18px;
      margin: 10px 5px;
    }
  
    .container {
      padding: 25px;
  
    }
  &lt;/style&gt;
  &lt;center&gt;
    &lt;h1&gt; Přidávání aktualit &lt;/h1&gt;
  &lt;/center&gt;
  
  &lt;form action="addarticle.php" method="post" enctype="multipart/form-data"&gt;
    &lt;div class="container"&gt;
      &lt;label for="jmeno"&gt;Název aktuality:&lt;/label&gt;
      &lt;input type="text" name="jmeno" id="jmeno"&gt;
      &lt;label for="editor"&gt;Text aktuality:&lt;/label&gt;
      &lt;input id="text" name="text" type="hidden"&gt;
      &lt;div id="editor"&gt;
        &lt;h1&gt;Nadpis aktuality&lt;/h1&gt;
        &lt;p&gt;Text aktuality&lt;/p&gt;
        &lt;p&gt;&lt;br&gt;&lt;/p&gt;
      &lt;/div&gt; &lt;button type="submit" name="aktualita"&gt;Přidat aktualitu&lt;/button&gt;
    &lt;/div&gt;
  &lt;/form&gt;
  &lt;script&gt;
    var quill = new Quill('#editor', {
      theme: 'snow'
    });
    var contentText = document.getElementByClassName('ql-editor');
    var hiddenInput = document.getElementById('text');
  
    // copy the text to input when the user writes in contentText div contentText.onkeyup = function() {
    hiddenInput.innerHTML = this.innerHTML; // 'this' is pointing to contentText }; 
  &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>The script I posted is a separate file which I am including in a pop up window on the main page.
  Thanks in advance !</p>