Expand my Community achievements bar.

Text Fill Pattern - JavaScript

Avatar

Former Community Member
I am needing to get a drop-down box to change different colors depending on the users selection. I have this working fine however the last choice changes the color to a solid fill with a diagonal line pattern. The color changes but the pattern never appears.



The color should be "yellow" with black diagonal lines going from left-upper to right-lower. Please look at what i coded and tell me where I missed it.



Grantee.subform1pg1.Q11DDB.border.fill.color.value = "255,255,153";

Grantee.subform1pg1.Q11DDB.border.fill.pattern.type = "toLeft";

Grantee.subform1pg1.Q11DDB.border.fill.pattern.color.value = "0,0,0";



I greatly appreciate any insight i have changed this dozens of times.



//heres the entire script_________

****----- Grantee.subform1pg1.Q11DDB::exit: - (JavaScript, client) -------------------------------------



if (Grantee.subform1pg1.Q11DDB.rawValue == 1)

{ Grantee.subform1pg1.Q11DDB.border.fill.color.value="211,211,211"; }

if (Grantee.subform1pg1.Q11DDB.rawValue == 2)

{ Grantee.subform1pg1.Q11DDB.border.fill.color.value="255,255,153"; }

if (Grantee.subform1pg1.Q11DDB.rawValue == 3)

{ Grantee.subform1pg1.Q11DDB.border.fill.color.value="255,255,160";

Grantee.subform1pg1.Q11DDB.border.fill.pattern.color.value="0,0,0";

Grantee.subform1pg1.Q11DDB.border.fill.pattern.type="diagonalRight";

}



Met
6 Replies

Avatar

Former Community Member
CORRECTION:



I noticed that I copied code from two different attempts. It should read like the top not what is coded on the last lines of the entire script I posted.



Thanks.



Met

Avatar

Former Community Member
Is the last selection the only one that uses a pattern? In Design mode, ensure the dropdown has focus and then click on the XML Source tab. The object with focus should be highlighted. Are there patterntyoe and patterncolor modes under the border nodes?

Avatar

Former Community Member
Paul,



Yes the last selection is the only one with the black diagonal lines.



The actual code is as follows in the Script Editor:



----- Grantee.subform1pg1.Q11DDB::exit: - (JavaScript, client) -------------------------------------



if (Grantee.subform1pg1.Q11DDB.rawValue == 1)

{ Grantee.subform1pg1.Q11DDB.border.fill.color.value="211,211,211"; }

if (Grantee.subform1pg1.Q11DDB.rawValue == 2)

{ Grantee.subform1pg1.Q11DDB.border.fill.color.value="255,255,153"; }

if (Grantee.subform1pg1.Q11DDB.rawValue == 3)

{ Grantee.subform1pg1.Q11DDB.border.fill.color.value="255,255,160";

Grantee.subform1pg1.Q11DDB.border.fill.pattern.color.value="0,0,0";

Grantee.subform1pg1.Q11DDB.border.fill.pattern.type="diagonalRight";

}



I'm not familiar with the focus of an object. Should I set something like this,

xfa.host.setFocus("xfa.Grantee.subform1pg1.Q11DDB");



As for the border nodes, I see no patterntype or patterncolor set anywhere. How would I confirm that there are no modes set on a node?



Thanks for your help!

Avatar

Former Community Member
If there was no pattern on the object to begin with then you cannot add a pattern to it. The nodes fill.pattern.color and fill.pattern.type do not exist in the template so you cannot change a value of something that does not exist. In Designer, can you add a pattern to that field (so that the nodes on the object exist). Then in the initialize event of the object you can set the fill.pattern.type = "" so that it looks right when you display the form to start.



Does that make sense?

Avatar

Former Community Member
Hi Met,

You can also at first set the diagonal right pattern to your dropdown in designer not script. Then you can set the pattern colors to border colors as:



if (this.rawValue == "1") { this.border.fill.color.value="211,211,211";

this.border.fill.pattern.color.value="211,211,211";

}

if (this.rawValue == "2") { this.border.fill.color.value="255,255,153";

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

}

if (this.rawValue == "3") { this.border.fill.color.value="255,255,160";

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

this.border.fill.pattern.type="diagonalRight";

}



Asiye

asiyegunaydin@kgc.com.tr

Avatar

Former Community Member
Thanks a lot for bot of your help, that worked. I was not clear on setting the node.



I'm getting much better at LiveCycle and JS though!!!