Expand my Community achievements bar.

Possibility of Field Colors

Avatar

Level 4

I get a bit confused...

Right now I have 2 mainly similar forms. 90% of the fields of both are totally identical (I copied them from one form to the other).

Now I copied a field (that already existed) in the other form with the following script:


if (this.rawValue == 1){Kontrollkästchen2.fillColor = "0,220,0";}

In the first form, this script makes the whole "Kontrollkästchen2" (Checkbox2) green (including the writing field).

In the second form the identical field makes just the small checkbox of Checkbox2 green (only when clicked).

And here are my questions:

1) has anybody any idea, where the difference between the two forms could be?

2) what options do I have on coloring the fields and what are the javascripts for it? (Like fillColor/border etc.)

Sorry for troubling

Lisa

6 Replies

Avatar

Former Community Member

Is the target version for both forms the same? There are a number of ways to deal with coloring fields.....it might be easier if you describe the effect that you want and we give you the commands.

Paul

Avatar

Level 4

Think they are...

I created both forms same day, same hour, same minute as one form with very long scripts and one form to create those scripts. Now I dumped the less performant one since it got some other perfomance problems too (and created it anew by coppying the performant one)... but... well... I am still a bit curious though ^^

A border or something like that would be cool, because the only thing it will be used for is: to compare some choices the user makes.

Example: User checks a checkbox that checks itself 10 other checkboxes.

Then the user changes the checks to colored something.

User checks another checkbox that checks 5 other checkboxes.

Then the user changes the checks to border color.

These colors will then make the comming up final choices easier.

Avatar

Level 10

Hi,

I am not sure if this is of help, but we had a form that gave visual feedback on the status of checkboxes

If the checkbox was unchecked, the fill was a light red (to indicate that the field was not answered) and the caption font was normal (to indicate that the checkbox was not selected).

If the user clicked the checkbox the fill changed to green and the caption font changed to green and bold (which highlighted the selected choices to the user).

Javascript in the mouseUp of the main checkboxes might look like:

var fld1 = xfa.resolveNode("form1.page1.Kontrollkästchen1.ui.#checkButton.border.fill.color");

if (this.rawValue == 0)
{
    this.caption.font.weight = "normal";
    this.caption.font.fill.color.value = "0,0,0";

    fld1.value = "255,225,225";
    Kontrollkästchen2.rawValue = 0;

     ...

    Kontrollkästchen23.rawValue = 0;
}
if (this.rawValue == 1)
{
    this.caption.font.weight = "bold";
    this.caption.font.fill.color.value = "0,128,0";

    fld1.value = "225,255,225";
    Kontrollkästchen2.rawValue = 1;

     ...  

    Kontrollkästchen23.rawValue = 1;
}

Because you are controlling the on/off of the other (secondary) checkboxes it would be important to make sure that their value while calculated, can be overriden by the user (object / value tab).

The Javascript in the form: layout ready of the secondary checkboxes would be slightly shorter (this example for Kontrollkästchen2):

var fld1 = xfa.resolveNode("form1.page1.Kontrollkästchen2.ui.#checkButton.border.fill.color");

if (this.rawValue == 0)
{
     this.caption.font.weight = "normal";
     this.caption.font.fill.color.value = "0,0,0";

    fld1.value = "255,225,225";
}
if (this.rawValue == 1)
{
    this.caption.font.weight = "bold";
    this.caption.font.fill.color.value = "0,128,0";

    fld1.value = "225,255,225";
}

Note that for the #checkButton.border.fill.color to work each checkbox, they must have a default white background fill.

I hope that this is of help.

N.

Avatar

Level 4

Yeah that helped a bit... (though somehow the script only changed the Textcolor...

Another problem I have is right now I have the following script on a button:

if
(Controll2.rawValue == 1)
{Controll2.fillColor = "255,0,0";
Controll2.rawValue = 0;}

Colors Controll2 red when marked.

On another button I have:

if
(Controll2.fill Color != "255,255,255")
{Controll2.fillColor = "255,255,255";}

To paint controll2 white again.

Works this far... the only thing is, the black boarders of the red colored field won't dissappear.

Any ideas?

Avatar

Level 10

Hi Lisa,

There are a couple of points that I think you need to look at:

If you are trying to change the background colour of the field, then you need to access the user interface of the object first.

The line of script that sets the variable "fld" is very important:

var fld1 = xfa.resolveNode("form1.page1.Kontrollkästchen2.ui.#checkButton.border.fill.color");

The script in RED would follow the naming convention in your form.

The sets fld1 to the background fill property for a CheckBox only. You will need slightly different script for numeric fields; text fields, etc.

Have a look at: http://forums.adobe.com/message/1881908#1881908 and http://forums.adobe.com/message/1359192#1359192

I would recommend the Adobe document Calculations and Scripts, which sets out how to script for various properties of all of the objects. It is available here.  http://partners.adobe.com/public/developer/en/tips/CalcScripts.pdf

I am not sure of your work / form process and why you have the script in buttons. You could have the script in the Layout: Ready event of the checkbox. If you want to change the background fill of the checkbox the Javascript would look like this:

var fld = xfa.resolveNode("form1.page1.Controll2.ui.#checkButton.border.fill.color");


if  (this.rawValue == 1)
{

     fld.value = "255,0,0";

}

else

{

     fld.value = "255,255,255";

}

The other objects could then affect the value of the Checkbox and let the visual appearance to the checkbox itself.

This will change the background colour (provided that it is set to white initially in the Field / Object tab - custom appearance first). It will not change the colour of the caption or borders. Have a look at the two images in the post above and if that is what you want to achive this approach should help you.

viel Glueck,

Niall

Avatar

Level 4

I will look at it for a while... (tomorrow... today is just to late to get that all into my brain)


About your question regarding "Why having the script in buttons".

It is like that:

At the beginning the user can choose of a high amount of checkboxes.

If the choices he made are possible in combination he will have a button available that links him to a Homepage.

If not, he has to rechoose till he gets access to a button.

But this is somehow a labyrinth.

To make it a bit simpler there are "solution" checkboxes under each button that will show (in color) all checkboxes that can be chosen and won't make the specific field invisible. If he doesn't like the coloring he did, it should be whitened again, so he can color another solution.

All in all this is something like a very small user oriented database with quicklinks made especially for quick decisions.

I know, there are better platforms to do something like this and most likly I'll get it later on somewhere else... but right now the solution I builded is quite okey...