title: change div colour with js if else conditiond
body: <p>I hope someone can help with this.  I'm trying to change the background colour of a "div id" using an if else statement.  So that if "udata" is greater than 70 the background of the box containing the result will turn green, or based on the other if conditions other colours.  Once I can get this to work the "udata" value will be supplied by a php pull from a database.</p>
  
  <p>I've search the existing links but I haven't found this combination of colour change, div background and if else statements.</p>
  
  <p>Any help would be appreciated.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;link rel="stylesheet" href="BoxTEST.css"&gt;
      &lt;script type="text/javascript"&gt;
        function () { 
  
          var udata = [53];
  
          if (udata &gt;= 70) {
          document.getElementById("centerbox1").style.backgroundColor = '#99C262';
          }
          else  
          if (udata &gt;= 51 &amp;&amp; udata.value &lt;70)  
          {
          document.getElementById("centerbox1").style.backgroundColor = '#F8D347';
          }  
          else  
          if (udata &lt;=50)  
          {
          document.getElementById("centerbox1").style.backgroundColor = '#FF6C60';
          }
       }
   &lt;/script&gt;
   &lt;/head&gt;
    &lt;body&gt;
      &lt;div class="containerbox"&gt;
          &lt;div id="centerbox1" style= min-width:25%; max-height: 90px"&gt;
            &lt;div class="value"&gt;
            &lt;p&gt;&lt;span style="color: #fff ;font-weight:bold; font-size:36px"&gt;53%&lt;/span&gt;
            &lt;br&gt;
            &lt;span style="color: #fff ; font-weight:bold"&gt;Utilisation&lt;/span&gt;&lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
     &lt;/div&gt;
    &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>