Skip to Content
0
Jun 22, 2016 at 03:56 PM

Dynamic alter colour cell with JavaScript

27 Views

Hello Guys,

I'm facing the current problem:

I want change a colour cell depends on the value of the cell variable. I'm using the following JavaScript code on the initialize event of this cell

data.First.MainTable.Table1.Row1.Cell6::initialize - (JavaScript, client)

var numrows = xfa.resolveNodes("data.First.MainTable.Table1.Row1[*]").length;

for (var i = 0; i < numrows; i++)

{

var LV_DATA = xfa.resolveNode("data.First.MainTable.Table1.Row1[" + i + "].Cell6");

switch(LV_DATA){

case LV_DATA <= "2":

this.border.fill.color.value = "0, 153, 0";

break;

case LV_DATA >= "3" && LV_DATA <= "6":

this.border.fill.color.value = "255, 255, 0";

break;

case LV_DATA> "6":

this.border.fill.color.value = "255, 0, 0";

break;

default:

this.border.fill.color.value = "255, 255, 255";

}

}

My output values is:

With this output on collumn RISK Level i should get the first two cells red and the last one yellow.

Can you help me?

Attachments

Print1.PNG (35.4 kB)
Print2.PNG (10.2 kB)