Expand my Community achievements bar.

java script

Avatar

Level 3

I want to change the color of front automatically from black to red due to negative value in the numeric field in adobe livecycle designer. I think for this I need a java script.Have u any script like this?

8 Replies

Avatar

Level 10

Hi,

The following JavaScript in the exit event should work:

if (this.rawValue < 0) {

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

          this.caption.font.fill.color.value = "0,0,0";

}

else {

          this.font.fill.color.value = "0,0,0";

}

Niall

Avatar

Level 3

but in the script show field what should be kept?

Avatar

Level 10

In the Show dropdown you would select "calculate" event. Then in the Script editor (5), you would try in your script:

LC Designer Workspace.png

Hope that helps,

Niall

Avatar

Level 3

but it works in the form which is made by only lyvecycle but it does not work with the form which is made by acrobat pro and finaly edited by life cycle. My form is made by acrobat pro and then it is edited by livecycle. In such case what can I do?

Avatar

Level 10

Hi,

Forms created in Acrobat (AcroForm) are completely different to forms created in LC Designer (XFA Forms). I would not be inclined to edit an AcroForm in LC Designer.

You should be able to add script in Acrobat to achieve what you are looking for. Something like:

var oField = this.getField("NumericField1");

if (oField < 0) {

     oField.textColor = color.red;

}    

else {

     oField.textColor = color.black;

}  

Please note that this JavaScript would be inserted into the field in Acrobat AND NOT in LC Designer.

I would recommend that you repost your question to the Acrobat Scripting forum: http://forums.adobe.com/community/acrobat/acrobat_scripting.

Good luck,

Niall

Avatar

Level 3

I have tried for the acrobat but it does not work. what can I do? I have insert the script in the text field properties> action> run a jav script. Is it correct? or i have to insert any other place?

Avatar

Level 3

in the script I think I have to change the field name NumaricField1.Am I right? do I have to change the oField.?

Avatar

Level 10

Hi,

I am missing the .value from the script above, eg

if (oField.value < 0) {

See an example here: http://assure.ly/u6X2Jt.

Please note that you can achieve similar results without script in the Format tab:

Acrobat1.png

Niall