I want to color the field on my form, but my Client Script doesn't work.

Csaba B_rsics
Tera Contributor

Hi everyone!

I created an onChange client script to change the color of a reference field on my form when it changes, but somehow my code doesn't work. The trigger condition is the same field that's color should be changed.  

 if (conditionValue == "1") {
        
            var element = g_form.getElement('reference_field');
            element.style.backgroundColor = "red";

        }

1 ACCEPTED SOLUTION

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi,

User getDisplayBox() instead of getElement().

e.g.

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
	
    var c = g_form.getDisplayBox('user');
    c.style.backgroundColor = 'red';

}

execution result:

find_real_file.png

View solution in original post

5 REPLIES 5

Harish KM
Kilo Patron
Kilo Patron

Can you share entire script? what field is "conditionValue "?

 

Regards
Harish

conditionValue is a returned integer from a function.(There was an additional condition for this but my code is quite long, that's why I only added this part). I debugged everything so the code works fine, except he coloring part.

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi,

User getDisplayBox() instead of getElement().

e.g.

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
	
    var c = g_form.getDisplayBox('user');
    c.style.backgroundColor = 'red';

}

execution result:

find_real_file.png

how to do it for onload function