Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Change font color by javascript on exit

Avatar

Level 4

I would like to change the font color of textfieldB when the user exits textfieldA by means of JS

Right now, I am using textfieldB.fontColor = "0,0,0"; (the font color is originally (255,0,0)

When I preview the form, nothing happens. No error in the console, no changing colors.

What am I doing wrong?

Graham

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

The issue is that the field you are trying to set is not a TextField but a regular Text object. The fontColor is not a valid property of that object. To get at the Text objects font color use this expression:

PlainText.font.fill.color.value

= "0,0,0";

Paul

View solution in original post

9 Replies

Avatar

Level 10

Hi Graham,

Seems to work for me, I've attached a sample, hope that helps.

Bruce

Avatar

Level 4

Hmmm, curious....

Yes, BR, yours does work. So I altered your example to more closely fit my needs and it appears something I left out is causing the problem. See the attached example.

To explain more robustly, I am filling a text box with the contents of user input from a text field. As long as I keep the second text field, it works, but although I can copy the contents of the text field to a text box, the fontColor doesn't work.

Avatar

Correct answer by
Former Community Member

The issue is that the field you are trying to set is not a TextField but a regular Text object. The fontColor is not a valid property of that object. To get at the Text objects font color use this expression:

PlainText.font.fill.color.value

= "0,0,0";

Paul

Avatar

Level 4

Thanks Paul, that did the trick.

I notice that there is no mention of this in the LiveCycle Designer ES Scripting Reference document. Is this because it's not a standard call, or is it because I should figure that fill.color.value can be applied to many things and not just the few mentioned in the reference?

Anyway, thanks!

Graham Calhoun

Avatar

Former Community Member

Actually what I do is look at the XML source to see what path is being used to set the value ...then I merely duplicate it in the call. In the docs each property and method is defined ...you just need to know that color is a subset of fill etc.

The fillcolor is a shortcut that was added to a TextField to make it easier than having to go through the whole path.

Paul

Avatar

Level 4

When you said: "Actually what I do is look at the XML source to see what path is being used to set the value..." I thought, Voila! That's how I can quickly get path information to add to scripts (I'm a REAL newbie).

Having not looked at the XML Source tab much before, I quickly went to check it out. Unfortunately, I see nothing related to hierarchy in the XML source. Are we looking at the same thing?

Graham

Avatar

Former Community Member

Yes we are ....once in the XML source you can click on an object in the hierarchy and the cursor will move to that definition. In the case of your Text object here is the XML that defines it:

Note that the name attribute of the draw is "PlainText". Then below that we have a font definition ....so following the hierarchy of the XML we get:

PlainText.font.fill.color.value

In some case the value attribute is implied and in others it is stated in the structure. If I wanted to get at the text that is being displayed I would use:

PlainText.value.text.value

Make sense?

Paul

Avatar

Level 4

Ahhh, yes! I DO see! Thanks a bunch!

Graham

Avatar

Level 10

Great tip - thanks Paul!

Makes understanding what's going on much easier.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----