Applying Color Coding to a SharePoint List. - SharePoint Customization - SharePoint for All - Dell Community

Applying Color Coding to a SharePoint List.

Applying Color Coding to a SharePoint List.

This question is not answered

Hi!

Can anyone share their knowledge with me, regarding an error message that I received from a JavaScript that was developed in Notepad.  The error message that I receive and the JavaScript that I developed are as follows:

Error Message

Script: C:\Users\robertsd\Desktop\Conditional Severity.js

Line: 1

Char: 1

Error:  Syntax Error

Code: 800A03EA

Source:  Microsoft JScript compliation error

Developed JavaScript:

<script type="text/JavaScript">
function DisplaySeverity(severity)
{
        var imgSrc = ' ';

        if (severity == '(1) OVERDUE’)
            {
                         imgSrc = ‘teamspace.merck.com/.../Overdue.png';
             }
             else if (severity == '(2) Alert')
             {             
                        imgSrc = ‘teamspace.merck.com/.../Alert.png';
             }
             else if (severity == '(3) ON TIME')
             {
                       imgSrc = ‘teamspace.merck.com/.../On%20Time.png';
             }
             else if (severity == '(4) Completed On Time')
             {
          imgSrc = ‘teamspace.merck.com/.../Completed%20On%20Time.png&rsquo;;
      }
             return  ‘<img alt=”’ + severity + ‘” src=’” + imgSrc + ‘”>’;
             }
</script>

 Thanks in advance for your response.

David

 

All Replies
  • Hi David,

     

    At the first sight for the script, I noticed that some single quotes and the double quotation marks are wrong in the script, I am not sure whether it is the editor issue. I have modify it, you could take a try.

     

    <script type="text/JavaScript">

    function DisplaySeverity(severity)

    {

           var imgSrc = ' ';

           if (severity == '(1) OVERDUE')

               {

                             imgSrc = 'teamspace.merck.com/.../Overdue.png';

                 }

                 else if (severity == '(2) Alert')

                 {            

                           imgSrc = 'teamspace.merck.com/.../Alert.png';

                 }

                 else if (severity == '(3) ON TIME')

                 {

                           imgSrc = 'teamspace.merck.com/.../On%20Time.png';

                 }

                 else if (severity == '(4) Completed On Time')

                 {

             imgSrc = 'teamspace.merck.com/.../Completed%20On%20Time.png&rsquo';

                 }

                 return '<img alt="' + severity + '" src="' + imgSrc + '">';

                 }

    </script>

     

    Kenny.