0

I would like to clean up a text area with javascript. Searching the net I found only jQuery or JavaScript functions to do this, but they don't work for me. After pressing the button called 'AVANTI', I would like the text area to be completely clean and then if the user presses the button again to show him more data from MySQL database. I tried to use the reset() function inside the 'AVANTI' button, but once pressed it is no longer possible to view other data inside the textarea. My textarea is overwritten by data everytime I press 'AVANTI' button. My main question is where to put document.getElementById('comments').value = ''; in my JS code?

<html lang="it" dir="ltr">
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
        <script type="text/javascript">
    $(document).ready(function(){
  window.history.replaceState('','',window.location.href)
  });
    $(document).ready(function(){
   $('#comments').bind("cut copy paste",function(e) {
      e.preventDefault();
   });
});
      $(document).ready(function() {
        var commentCount = 0;
        $("#avanti").click(function() {
          commentCount += 1 ;
          $("#comments").load("load-comments.php",  {
            commentNewCount: commentCount
          }); });  });
    </script>
    <title>Cherubini Website</title>
    <meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
  </head>
  <body>
    <textarea name="message" rows="8" cols="80" id="comments"
     readonly="readonly" unselectable="on">
<?php""?>
    </textarea>
    <button id="indietro">INDIETRO</button>
    <button id="avanti">AVANTI</button>
  </body>
</html>

0 Answers0