title: If text in a cell contains a specific word then put an image in it
body: <p>I hope someone can help me. How can I a put an Image in a td if there is a specific word in it? Here is my code:</p>
  
  <pre><code>    var allTableCells = document.getElementsByTagName("td");
  
      for (var i = 0, max = allTableCells.length; i &lt; max; i++) {
          var node = allTableCells[i];
  
  
          var currentText = node.childNodes[0].nodeValue;
  
  
          if (currentText === "ArmHW")
              node.style.backgroundImage = "url('HW.png')"
  </code></pre>
  
  <p>P.S. Sorry for my english! And thank you!</p>
  
  <p>Here is the complete code now... still not working =/</p>
  
  <pre><code>var allTableCells = document.getElementsByTagName("td");
  var HW = new Image();
  yourHW.src = "HW.png";
  
  for (var i = 0, max = allTableCells.length; i &lt; max; i++) {
      var node = allTableCells[i];
  
      var currentText = node.childNodes[0].nodeValue;
  
      if (currentText === "@WebSecurity.CurrentUserName")
          node.style.color = "Blue"; 
          node.style.border = "solid"
  
  }
  
  for (var j = 0, max = allTableCells.length; j &lt; max; i++) {
  var node = allTableCells[j];
  if (Text.toString().trim() === "ArmHW") {
      node.removeChild(Text);
      node.appendChild(yourHW);
       }
  </code></pre>
  
  <p>Ok the last saved code is this one... Still doesn't work:
  (Sorry for my english and lack of knowledge)</p>
  
  <pre><code>&lt;script&gt;
  var allTableCells = document.getElementsByTagName("td");
  
  
  for (var i = 0, max = allTableCells.length; i &lt; max; i++) {
      var node = allTableCells[i];
  
      var currentText = node.childNodes[0].nodeValue;
  
      if (currentText === "@WebSecurity.CurrentUserName")
          node.style.color = "Blue"; 
          node.style.border = "solid";
  
  }
  var allTableCells = document.getElementsByTagName("td");
  
  for (var i = 0, max = allTableCells.length; i &lt; max; i++) {
      var node = allTableCells[i];
  
  
      var currentText = node.childNodes[0].nodeValue;
  
  
      if (currentText === "ArmHW")
          node.style.backgroundImage = "url('HW.png')"
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>And here is a sample of the td we are talking about:</p>
  
  <pre><code>       &lt;table id="91" class="csmap"&gt;@foreach(var row in db.Query(selectCommand, Searcdb.Query(selectCommand, SearchTerm90)){&lt;tr&gt;&lt;td onmouseover="this.style.border='dashed'" onmouseout="this.style.border='solid'"&gt;@row.Owner&lt;br&gt;@row.Owner2&lt;/td&gt;&lt;/tr&gt;}&lt;/Table&gt;
  </code></pre>
  
  <hr>
  
  <p>Ok, it looks like all your code are right... Something in my page is causing disfunction... I can't put an image in the back of any td... </p>
  
  <p>I'm trying to rewrite my page step by step and see where it stops. If you have any idea do not hesitate =D</p>
  
  <hr>
  
  <p>Ok, something is missing. The code is working only if there is only one word in the td... My td's contain word<br>word<br>etc...</p>
  
  <p>The script must find the good word in the td and show an image</p>