# "Add color to a specific field value in a view." isn't working

**URL:** <https://forums.knack.com/t/add-color-to-a-specific-field-value-in-a-view-isnt-working/10145>\
**Category:** API & Custom Code\
**Created:** [July 25, 2016, 4:13pm UTC](https://forums.knack.com/t/add-color-to-a-specific-field-value-in-a-view-isnt-working/10145 "2016-07-25T16:13:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeeMoreau36934](https://avatars.discourse-cdn.com/v4/letter/l/9dc877/32.png) [@LeeMoreau36934](https://forums.knack.com/u/LeeMoreau36934)\
**Post date:** [July 25, 2016, 4:13pm UTC](https://forums.knack.com/t/add-color-to-a-specific-field-value-in-a-view-isnt-working/10145/1 "2016-07-25T16:13:02Z")

</div>

Hi everyone,

I'm following the examples under support for "[Add color to a specific field value in a view.](http://helpdesk.knackhq.com/support/solutions/articles/5000447560-javascript-code-examples#addcolorfields)" to make a field on a form red when the value is "Need to Submit".

My values are:

Page\_ID is scene\_22

View\_ID is view\_29

"Request Status" field that contains the "Need to Submit" value is field\_64

I don't see anywhere in the code where it asks for page ID or scene, so I have the code as follows:

// Your app's ViewID and FieldID will need updated.

$(document).on('knack-view-render.view\_29', function(event, view, data) {

&nbsp; &nbsp;

&nbsp; &nbsp; $("#view\_29 td.field\_64").each(function() {

&nbsp; &nbsp; &nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; var textColor = ($(this).find("span").text().trim() == "Need to Submit") ? "#ff0000" : "#1c631f"; // #ff0000 is red and the #1c631f is green

&nbsp; &nbsp; &nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; $(this).css("color", textColor);

&nbsp; &nbsp;

&nbsp; &nbsp; })

&nbsp;

});

This doesn't work though the text just stays black. &nbsp;I'm not entirely clear how the colours work in terms of when it goes red or green like in the example, so left it at default just to see what it does but no matter what I try it never changes the colour from black. &nbsp;Am I missing something?

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [December 26, 2017, 8:56am UTC](https://forums.knack.com/t/add-color-to-a-specific-field-value-in-a-view-isnt-working/10145/2 "2017-12-26T08:56:12Z")

</div>

&nbsp;Hello,

Instead of "&nbsp;$("#view\_29 td.field\_64").each(function() {"

can you try "&nbsp;$("#view\_29").find("td.field\_64").each(function() {"

---

<div class="post-metadata">

**Author:** ![MichaelMoo15586](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/michaelmoo15586/32/1569_2.png) [@MichaelMoo15586](https://forums.knack.com/u/MichaelMoo15586)\
**Post date:** [February 2, 2017, 7:58pm UTC](https://forums.knack.com/t/add-color-to-a-specific-field-value-in-a-view-isnt-working/10145/3 "2017-02-02T19:58:58Z")

</div>

Hi Lee

Did the team get back to you on this? I am having precisely the same problem.

I'm wondering if there is an error in the example, but as jquery isn't my strong point I can't be sure.

Would appreciate a steer.

Thanks

&nbsp;

Mike Moore
