title: Get text from live preview to php and convert
body: <p>I have created this live-preview thingy that works perfectly, but new lines and so on doesn't show, and also I have a bb-codes function I would my text to go through. So that text in the textarea <code>[b]Hello world[/b]</code> is <strong>Hello world</strong></p>
  <p>This is my code so far:</p>
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js&quot;&gt;&lt;/script&gt;
  
      &lt;/head&gt;
      &lt;body&gt;
          &lt;textarea name=&quot;WPcomment&quot; id=&quot;WPComment&quot; placeholder=&quot;Legg til tekst...&quot;&gt;&lt;/textarea&gt;
          &lt;br&gt;
          &lt;input type=&quot;button&quot; class=&quot;button&quot; name=&quot;answer&quot; value=&quot;Live-preview&quot; onclick=&quot;showDiv()&quot; /&gt;
          &lt;div style=&quot;display:none;&quot; id=&quot;prevCom&quot;&gt;&lt;/div&gt;
      &lt;/body&gt;
          &lt;script type=&quot;text/javascript&quot;&gt;
              
          var wpcomment = document.getElementById('WPComment');
  
          wpcomment.onkeyup = wpcomment.onkeypress = function(){
              document.getElementById('prevCom').innerHTML = this.value;
          }
          
          function showDiv() {
             document.getElementById('prevCom').style.display = &quot;block&quot;;
          }
          
          &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>
  <p>Jsfiddle: <a href="https://jsfiddle.net/mhp57cno/" rel="nofollow noreferrer">https://jsfiddle.net/mhp57cno/</a></p>
  <p>The php that I use when I output text from my database is this:</p>
  <pre><code>$htmltext = htmlspecialchars($htmltext);
  $htmltext = showBBcodes($htmltext);
  
  echo $htmltext;
  </code></pre>
  <p>What I basicly want is the text from <code>#prevCom</code> to output as the <code>$htmltext</code> from above</p>