Expand my Community achievements bar.

SOLVED

Display Positive Symbol

Avatar

Level 2

Is there a way to display the positive (plus) sign when a calculation result is positive?

1 Accepted Solution

Avatar

Correct answer by
Level 2

Ok. After playing around for a bit I figured it out. I ended up with this script. It will change the numerical field background color based on a positive, negative or neutral value and it will also display the positive/negative sign. With your help radzmar I was able to finish this. Thanks.

var num1 = (xfa.resolveNode("form1.#subform.CurrentWeight[9]").rawValue) - (xfa.resolveNode("form1.#subform.PrevWeight[9]").rawValue)

if (num1 > 0)

{

this.fillColor = "252,194,194";

this.format.picture = "num{'+'zz9.zz} 'lbs.'";

}

else if (num1 < 0)

{

this.fillColor = "194,252,194";

this.format.picture = "num{zz9.zz} 'lbs.'";

}

else if (num1 == 0)

{

this.fillColor = "194,194,252";

}

this.rawValue = num1;

View solution in original post

7 Replies

Avatar

Level 10

I don't think this is possible through Patterns. However, you can change it through scripting.

Note that you can't do it on a Numeric Field. It should be a Text Field instead.

nith

Avatar

Level 10

You can use a script in the change event to switch between display patterns.

Avatar

Level 2

This didn't work for me. I tried switching it to a text field and it still didn't work. I'm wondering if it has anything to do with the values being calculated instead of user inputting data. Oh well. Not a huge deal, just curious.

Avatar

Level 10

Sorry, missed the fact it's calculated.

Try this in the calculate event.

Avatar

Level 2

Yes. It does the plus and I added the minus sign but it doesn't show the calculate value!! Just shows zero with a minus or positive symbol depending on value.

Avatar

Correct answer by
Level 2

Ok. After playing around for a bit I figured it out. I ended up with this script. It will change the numerical field background color based on a positive, negative or neutral value and it will also display the positive/negative sign. With your help radzmar I was able to finish this. Thanks.

var num1 = (xfa.resolveNode("form1.#subform.CurrentWeight[9]").rawValue) - (xfa.resolveNode("form1.#subform.PrevWeight[9]").rawValue)

if (num1 > 0)

{

this.fillColor = "252,194,194";

this.format.picture = "num{'+'zz9.zz} 'lbs.'";

}

else if (num1 < 0)

{

this.fillColor = "194,252,194";

this.format.picture = "num{zz9.zz} 'lbs.'";

}

else if (num1 == 0)

{

this.fillColor = "194,194,252";

}

this.rawValue = num1;