title: HTML/JS - Block one button by another button and reset it by another button
body: <pre><code>&lt;body&gt;
  &lt;script&gt;
  MQTTconnect();
  
  var clicked_f = 0;
  var clicked_b = 0;
  
  if (clicked_f &gt; 0) {
      document.getElementById(&quot;backw_button&quot;).disabled = true;
      alert(&quot;BACKWARD button is disabled.&quot;);
  }
  if (clicked_b &gt; 0) {
      document.getElementById(&quot;fwr_button&quot;).disabled = true;
      alert(&quot;FORWARD button is disabled.&quot;);
  }
  if (document.getElementById(&quot;stop_b&quot;).clicked == true) {
      clicked_f = 0;
      clicked_b = 0;
  }
  else{
      document.getElementById(&quot;backw_button&quot;).disabled = false;
      document.getElementById(&quot;fwr_button&quot;).disabled = false;
  }
  
  function c_for() 
  {
      message = new Paho.MQTT.Message(&quot;1&quot;);
      message.destinationName = &quot;train/direction&quot;;
      mqtt.send(message);
  }
  function forw() 
  {   
      mqtt = new Paho.MQTT.Client(host,port,&quot;clientjs&quot;);
      var options = {
          timeout: 3,
          onSuccess: c_for,
          };   
      mqtt.connect(options);
  }
  
  function c_back() 
  {
      message = new Paho.MQTT.Message(&quot;2&quot;);
      message.destinationName = &quot;train/direction&quot;;
      mqtt.send(message);
  }
  function forw() 
  {
      mqtt = new Paho.MQTT.Client(host,port,&quot;clientjs&quot;);
      var options = {
          timeout: 3,
          onSuccess: c_for,
          };   
      mqtt.connect(options);
  }
  
  function MQTTconnect() 
  {
  console.log(&quot;connecting to &quot;+ host +&quot; &quot;+ port);
  mqtt = new Paho.MQTT.Client(host,port,&quot;clientjs&quot;);
  var options = {
      timeout: 3,
      onSuccess: onConnect,
      };
       
  mqtt.connect(options);
  }
  
  &lt;/script&gt;
  
  &lt;div class=&quot;inputik&quot; style=&quot;width: 290px;padding: 20px &quot;&gt;
          &lt;h3&gt;Direction:&lt;/h3&gt;
          &lt;button id=&quot;fwr_button&quot; onclick=&quot;clicked_f++;forw();&quot; style=&quot;background-color: #009600&quot;&gt;FORWARD&lt;/button&gt;
          &lt;button id=&quot;stop_b&quot; onclick=&quot;vyp()&quot; style=&quot;background-color: #990000&quot;&gt;STOP&lt;/button&gt;
          &lt;button id=&quot;backw_button&quot; onclick=&quot;clicked_b++;backw();&quot; style=&quot;background-color: #2247ff&quot;&gt;BACKWARD&lt;/button&gt;
  &lt;/div&gt;&lt;br&gt;
  </code></pre>
  <blockquote>
  <p>You cant press FORWARD button and BACKWARD in order, you must press STOP button between them. I just need disable one button by another button and vice versa and by STOP button enable both of them. MQTT doesnt matter i just need to disable one button at the time to not send messages. I just dont know where the mistake is</p>
  </blockquote>