1

I have a list with items that have columns where the user can select Yes or No to certain things, I would like to have it so any instance of Yes is in Green and any instance of No is red

enter image description here

The issue is I do not know how to write Javascript, once I have the code I can add a link to the JS file in the webpart

Thanks

0

You can use the below script in Script Editor Web part:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$Text = $("td.ms-cellstyle.ms-vb2:contains('Yes')");
$Text.css("background-color", "green");
$Text.css("font-weight", "bold");
$Text = $("td.ms-cellstyle.ms-vb2:contains('No')");
$Text.css("background-color", "red");
$Text.css("font-weight", "bold");
});
</script>
20
  • Hey thanks for the quick reply, that code has made the whole item red, the columns that are Yes or No are choice fields if that helps? Oct 18 '14 at 8:59
  • yes it would set the entire row red. Oct 18 '14 at 9:14
  • Hey, I would like only the text 'Yes' and 'No' to change colour, not the entire row Oct 18 '14 at 9:16
  • you can modify the jquery and try Oct 18 '14 at 9:31
  • I'm not sure what I need to modify Oct 18 '14 at 9:31
-1

You can just change the 2 lines that have background-color to font-color

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.