locked
Change colour of a section in Dynamics CRM using Jscript on change RRS feed

  • Question

  • Hello

    I am struggling to work out the jscript for changing the colour of a parent section of a picklist.

    For example a client wants a clear visibility of when an account is on stop. I can change the background of the picklist Value easily enough, but am having a little trouble working out how to change its parent sections colour. Any help really appreciated.

    The code I have for the picklist is as follows:

    var list = crmForm.all.p1_onstop;
    var option = list.options[1];
    //Set the background colour of the picklist to red
    option.style.backgroundColor = "#FF0000";
    option.style.borderColor = "#FF0000";
    option.style.color = "#000000";

    I believe the section is:
    parentElement.style.backgroundColor = "#FF0000";
    parentElement.style.borderColor = "#FF0000";

    but i could be a way off..

    thanks
    Matt
    Friday, March 12, 2010 2:38 PM

Answers

  • try

    crmForm.all.statuscode_c.parentElement.parentElement.parentElement.style.backgroundColor = "#FF0000";

    Regards
    Vinoth
    Friday, March 12, 2010 2:48 PM

All replies

  • try

    crmForm.all.statuscode_c.parentElement.parentElement.parentElement.style.backgroundColor = "#FF0000";

    Regards
    Vinoth
    Friday, March 12, 2010 2:48 PM
  • Hey thanks. i got round it in the end with this - had a few other spin offs from this but this is the crocks of it:

    if ((crmForm.all.p1_onstop.DataValue==1))
    {
    //Set the section color to red but keep field colour background white
    var list = crmForm.all.p1_onstop;
    var option = list.options[1];
    option.style.backgroundColor = "#FFFFFF";
    option.style.borderColor =  "#FF0000";
    option.style.color =  "#000000";
    crmForm.all.p1_onstop.parentElement.parentElement.parentElement.style.backgroundColor = "#FF0000";
    }
    //set back to normal if not on stop
    if ((crmForm.all.p1_onstop.DataValue==0))
    {
    crmForm.all.p1_onstop.parentElement.parentElement.parentElement.style.backgroundColor = "";
    }

    cheers
    Matt

    Friday, March 12, 2010 6:11 PM