title: Disable button with javascript
body: <p>I have a button. The button works fine. After I have pressed the button, then it shall not be possible to press the button again. It will be best if the button looks diabled.</p>
  <p>I have already tried with document.getElementById(&quot;id&quot;).disabled = true; but I can't make this work.</p>
  <p>PHP code for the button. The code makes a list of buttons. Each button has id= 1, 2, 3 etc.</p>
  <pre><code>if($_COOKIE[&quot;sorterdb&quot;]=='GR' || empty($_COOKIE[&quot;sorterdb&quot;])){$dblinjer[$i]['nrlink']='&lt;span id=&quot;para'.$i.'&quot;&gt;&lt;/span&gt;&lt;div class=&quot;s-12 l-12&quot;&gt;&lt;button type=&quot;button&quot; id=&quot;'.$i.'&quot; value=&quot;'.$dblinjer[$i]['loebid'].'_'.$dblinjer[$i]['tid'].'_'.$dblinjer[$i]['utcstart'].'&quot; onclick=baadimaal(&quot;baadimaal&quot;,this)&gt;'.$dblinjer[$i]['buttonnrsejl'].'&lt;/button&gt;&lt;/div&gt;';}
  </code></pre>
  <p>javascript:</p>
  <pre><code>function baadimaal(str,el) {
      var x = el.value
      var id = el.getAttribute(&quot;id&quot;)
      
      const xhttp = new XMLHttpRequest();
      xhttp.onload = function() {
          document.getElementById(&quot;container&quot;+id).innerHTML = this.responseText; //her placeres svaret, som kommer tilbage fra hide-ajax-svar filen
      }
      xhttp.open(&quot;GET&quot;, &quot;hide-ajax-svar.php?funk=&quot; + str + &quot;&amp;para=&quot; + x + &quot;&amp;i=&quot; + id); //overfør str og x til hide-ajax-svar filen
      xhttp.send();
  }
  </code></pre>