title: Change text color using if/else in javascript
body: <p>I hope someone can help me with this.I am new in javascript. I am trying to change the color of a text depending on the status in HTML file.</p>
  <pre><code>&lt;td id=&quot;payment_status_cl&quot; style=&quot;text-align: center; height:25px&quot;&gt;&lt;%=resultSet.getString(&quot;payment_status&quot;)%&gt;&lt;/td&gt;
  </code></pre>
  <p>It doesn't work if I insert if/else statement in the javascript. But it will work if there are no if/else statement. For example:</p>
  <p>This one only change the color of one status:</p>
  <pre><code>function f_color(){
  if (document.getElementById('payment_status_cl').value = 'Submitted') {
  document.getElementById('payment_status_cl').style.color = &quot;Green&quot;;}
  }
  f_color();
  </code></pre>
  <p>This didn't work.
  javascript:</p>
  <pre><code>&lt;script&gt;
  function f_color(){
  if (document.getElementById('payment_status_cl').value = 'Submitted') {
  document.getElementById('payment_status_cl').style.color = &quot;Green&quot;;
  }
  else if (document.getElementById('payment_status_cl').value = 'Pending') {
  document.getElementById('payment_status_cl').style.color = &quot;Orange&quot;;
  }
  else if (document.getElementById('payment_status_cl').value = 'Warning'{
  document.getElementById('payment_status_cl').style.color = &quot;Yellow&quot;;
  }
  else if (document.getElementById('payment_status_cl').value = 'Overdue') {
  document.getElementById('payment_status_cl').style.color = &quot;Red&quot;;
  }
  }
  f_color();
  &lt;/script&gt;
  </code></pre>
  <p>I already tried by adding div.</p>
  <pre><code>var status = document.getElementById(&quot;payment_status_cl&quot;);
  function fcolor() { 
      if (status === 'Submitted') {
        document.getElementById(&quot;centerbox1&quot;).style.backgroundColor = '#99C262';
      }
      else if (status === 'Pending')
      {
        document.getElementById(&quot;centerbox1&quot;).style.backgroundColor = '#F8D347';
      }  
      else if (status === 'Warning')  
      {
        document.getElementById(&quot;centerbox1&quot;).style.backgroundColor = '#FF6C60';
      }
    }();
  </code></pre>
  <p>but it doesn't work. I appreciate all the help given.</p>