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

Shree3
Tera Expert

Hi Csaba,

Please check if isolate script checkbox is set to true. If it's true please make it false and then test it again.

Thanks!