locked
Change Fonts and backgrounds of a field RRS feed

  • Question

  • Dear all, please help it's very urgent. I have the following problem: in a crm form I've inserted "new_date" field in a different sections, which are in different tabs. According to my code if the new_date is weekend it's background becames red color. This works, but only for one field. Please tell me how can I change my code to make it work for 2 fields (which are ectualy same fields with different lables) .

    It's realy very urgent!

    Thanks in advance!

    function CheckDate(x) {
        var deadline = Xrm.Page.getAttribute(x).getValue();
        if (deadline != null) {
            // alert(deadline);
            var DayNum = deadline.getDay();
            var holidayMonth = deadline.getMonth();
            var holidayDay = deadline.getDate();
    
            if (DayNum == "6" || DayNum == "0") {
                document.getElementById(x + "_c").style.backgroundColor = 'red';
                document.getElementById(x + "_d").style.backgroundColor = 'red';
                document.getElementById(x + "_c").style.color = 'black';
                document.getElementById(x + "_c").style.fontWeight = 'bold';
    
            }
            else
    
                if ((holidayDay == "1" && holidayMonth == "0") || (holidayDay == "2" && holidayMonth == "0") || (holidayDay == "3" && holidayMonth == "0") || (holidayDay == "28" && holidayMonth == "0") || (holidayDay == "8" && holidayMonth == "2") || (holidayDay == "24" && holidayMonth == "3") || (holidayDay == "1" && holidayMonth == "4") || (holidayDay == "9" && holidayMonth == "4") || (holidayDay == "5" && holidayMonth == "6") || (holidayDay == "21" && holidayMonth == "8")) {
                    document.getElementById(x + "_c").style.backgroundColor = 'red';
                    document.getElementById(x + "_d").style.backgroundColor = 'red';
                    document.getElementById(x + "_c").style.color = 'black';
                    document.getElementById(x + "_c").style.fontWeight = 'bold';
                }
                else {
                    document.getElementById(x + "_c").style.backgroundColor = '#f8f8fa';
                    document.getElementById(x + "_d").style.backgroundColor = '#f8f8fa';
                    document.getElementById(x + "_c").style.color = '#3B3B3B';
                    document.getElementById(x + "_c").style.fontWeight = 'normal';
                }
           
        }
    }


    • Edited by gMary Saturday, April 18, 2015 7:48 AM
    Friday, April 17, 2015 8:13 PM