• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Decimals showing when clicking in numberbox

New Here ,
Jan 10, 2021 Jan 10, 2021

Copy link to clipboard

Copied

I've made a calculating pdf in Adobe Actrobat Pro. I've made textboxes with the number feature and choosen showing 0 decimals. If i write 307 in the first box it's supposed to multiply by 0,123456 in the second box. It works and shows the number 38 with no decimals. I have no trouble with calculating. The problem though is when i press the second box with the number 38, it shows 37,900992. We don't want it to show the decimals as it's not imortant for the costumers... and also it dosen't look good.

 

Is there any way to get the decimals in the second box to dissapear when clicking in the box?

TOPICS
How to , PDF forms

Views

682

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 11, 2021 Jan 11, 2021

OK, then change it to use the following code as the custom calculation script:

 

event.value = (Number(this.getField("Text1").valueAsString) * 0.123456).toFixed(2);

Votes

Translate

Translate
New Here ,
Jan 10, 2021 Jan 10, 2021

Copy link to clipboard

Copied

1.png2.png

Adding this pictures to clearify my question.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 11, 2021 Jan 11, 2021

Copy link to clipboard

Copied

You need to change the field's actual value. The Format setting doesn't do that. It just changes how it is displayed. Which is why when you click into it it reverts to the actual value, the ones you're seeing.

In order to round it to 2 decimals you will need to perform the calculation using a script.

How are you currently doing it?

Alternatively, you can set the field as read-only, but keep in mind that doing that will still preserve the old value, just not show it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 11, 2021 Jan 11, 2021

Copy link to clipboard

Copied

Currently I'm using the Simplified field notation and typing Text1 * 0.123456.

I have read only already an you can still click on the box and mark the text but you cant edit it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 11, 2021 Jan 11, 2021

Copy link to clipboard

Copied

OK, then change it to use the following code as the custom calculation script:

 

event.value = (Number(this.getField("Text1").valueAsString) * 0.123456).toFixed(2);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 11, 2021 Jan 11, 2021

Copy link to clipboard

Copied

Hey thanks! 🙂

 

Next problem though. I get an error message if I try to get one textbox to devide with another one so I'm currently using this code in the costum calculation script:

 

var v1 = this.getField("Text4").value; //change field name as needed
var v2 = this.getField("Text3").value; //change field name as needed
var v = v1/v2;

if(!isNaN(v) && v2 != 0){
event.value = v;
}
else {
event.value = "";
}v

 

How do you combine this code with the one you sent? Or is there any other magic scripts out there?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 11, 2021 Jan 11, 2021

Copy link to clipboard

Copied

So the calculation isn't really what you said it was... Please provide an exact description.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 11, 2021 Jan 11, 2021

Copy link to clipboard

Copied

Sorry, I've got multiple boxes which all depend on eachother. I'm gonna try to explain as simple as possible.

 

Box1: Number of choice

Box2: Box1 * 0,123456

Box3: Box1 * 0,789

Box4: Box2 / Box3

 

So in Box 2 & 3 event.value = (Number(this.getField("Text1").valueAsString) * 0.123456).toFixed(2); works because i multiply the boxes.

In Box 4 we want to devide two boxes, which don't work for me in any other way than using the code i provided in the last post. If i use Box2 / Box3 in Simplified field notation on Box4, I get an error message everytime... so that's not an option. And when I use the code from last post i end up with 6 or 7 decimals when clicking in the box, same problem as I had before in the multiplication boxes, Box2 & 3

 

Does this make sense? Sorry, I try to explain as simple as possible. English isn't my first language.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 11, 2021 Jan 11, 2021

Copy link to clipboard

Copied

The two things are unrelated. You need to use one script to change the number of decimals in Box2 and Box3, and another to calculate the value of Box4 correctly.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 12, 2021 Jan 12, 2021

Copy link to clipboard

Copied

Yes, I'm aware of that. I need a way to calculate division without getting 6 decimals.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 12, 2021 Jan 12, 2021

Copy link to clipboard

Copied

LATEST

As the custom calculation script of Box4 enter the following:

 

var v1 = Number(this.getField("Box2").valueAsString);
var v2 = Number(this.getField("Box3").valueAsString);

if (v2==0) event.value = "";
else event.value = (v1/v2).toFixed(2);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines