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

Values keep updating when changing one of the values

New Here ,
Mar 02, 2024 Mar 02, 2024

Hello,

I'm encountering a problem when I'm updating the PRICE1 value, it also updates PRICE2 (divides PRICE2 by 1.2 too) and vice-versa. There is no other javascript code.
issue.png

My calculation order is : PRICE1 > TOTAL1 > PRICE2 > TOTAL2

 

Anyone can tell me where is the problem please ? Thank you

TOPICS
Acrobat SDK and JavaScript
278
Translate
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 ,
Mar 02, 2024 Mar 02, 2024

This is normal, as the calculation event is triggered when you change the value of any field in the file.

If set up correctly, this should not matter and should produce the right results. If it doesn't it means you have an error in your code or set-up, typically an incorrect calculation order, or a self-referencing calculation.

Translate
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 ,
Mar 03, 2024 Mar 03, 2024

Thank you for responding.

 

If I understand correctly, I cannot use "event.value" if I want PRICE1 and PRICE2 to be independent ?

I also tried to use "this.getField("PRICE1").value=this.getField("PRICE1").value/1.2" but it only divides by 1.2 once and stops doing it when I type another number in PRICE1 field (PRICE2 still gets divided by 1.2) and when I change PRICE2, PRICE1 divides by 1.2

 

below is my calculation order

order.png

and here is my JS script :

//<AcroForm>
//<ACRO_source>PRICE1:Calculate</ACRO_source>
//<ACRO_script>
/*********** appartient à : AcroForm:PRICE1:Calculate ***********/
this.getField("PRICE1").value=event.value/1.2
//</ACRO_script>
//</AcroForm>

//<AcroForm>
//<ACRO_source>PRICE2:Calculate</ACRO_source>
//<ACRO_script>
/*********** appartient à : AcroForm:PRICE2:Calculate ***********/
event.value=event.value/1.2
//</ACRO_script>
//</AcroForm>

 

Is there a solution so PRICE1 and PRICE2 stay independent ?

Thank you

 

Translate
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 ,
Mar 03, 2024 Mar 03, 2024
LATEST

This is what I mean by a "self-referencing calculation". You can't use a field's own value in its calculation.

The fields are independent of each other. The way you set it up makes them dependent on themselves, though.

 

[Edited: Can't... Not can]

Translate
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