How to change the style of a specific field using JavaScript based on a condition?

Amaan Zaffar
Giga Contributor

I want to change the style of a specific field using JavaScript based on a condition using Client Script

1 ACCEPTED SOLUTION

Afrith Shariff
Tera Guru

Hi there,

use getControl() in this scenario

Try specifying the condition in if statement and change the style using javascript like you normally do in DOM manipulations.

function onLoad() {
    var a = g_form.getControl('number');
    a.style = "background-color:blue;border-radius:50px;height:100px; ";
}

 

View solution in original post

3 REPLIES 3

Afrith Shariff
Tera Guru

Hi there,

use getControl() in this scenario

Try specifying the condition in if statement and change the style using javascript like you normally do in DOM manipulations.

function onLoad() {
    var a = g_form.getControl('number');
    a.style = "background-color:blue;border-radius:50px;height:100px; ";
}

 

Thankyou for your assistance.

suvro
Mega Sage
Mega Sage

You can use the control

 

var f = g_form.control('field_name');

f.style.background_color = value