These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to format values in a PDF form

excellionroto2
Registered: May 10 2010
Posts: 12
Answered

Hello all,

I am trying to format numeric values using Javascript code.

For example,

I place the next code in an exit event of a determined field:

var vValue = formname.field.rawValue;
var vValue2 = formname.field.formattedValue;
console.println(vValue);
console.println(vValue2);

I fill the gap with "1234" and the result in console is:
vValue = 1234
vValue2 = 1.234

Is there any way to assign a determined format?
I am looking for to get 1.234 $ or 1.234 €, etc,... depending on the value of another field.

Thanks in advance.

Best regards,
Roberto

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
You can use and also define own pattern for your form fields in the object tab.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

excellionroto2
Registered: May 10 2010
Posts: 12
Hello radzmar,

Thank you for your response.

My purpose is the next (I would like to leave blank all patterns in an Object an define them in execution depending on a specified values. Only my fields are defined as Numeric fields and Data Format "Float"):

I would like to do something as the next example,

1- Get system locale using the property (formname.locale)
2- If locale = "es_ES" and my currency field is set to euros, ...
If the field is filled with the value "1234", I would like to get the value "1.234 €"
3- If locale = "en_US" and my currency field is set to dollar,...
If the field is filled with the value "1234", I would like to get the value with a dollar symbol appended.

Depending on the previous field values, I would like to get the number in the specified language and format.

I have the idea, but the problem is how to set the formats in execution mode. Is it possible to do that?. Which is the better event to place the code in order to do my purpose?

Thanks in advance.

Best regards,
Roberto
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Roberto,

you can use a script in the layout:ready event of your numeric fields to check out the locale property.
To get the currency symbol automatically adapted to the current locale formatting you need to define a pattern "num{zzzzzzzz9.99 $}" for the numeric fields to.

var ChkLocale = Form1.locale if(ChkLocale == "en_US"){this.locale = "en_US";}if(ChkLocale == "es_ES"){this.locale = "es_ES";}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

excellionroto2
Registered: May 10 2010
Posts: 12
Thank you for your response, it was very useful.

Best regards,
Roberto