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

1 radio button group that inserts data into a field that is used in 1 of 3 calculations

New Here ,
Jan 15, 2025 Jan 15, 2025

I have 2 radio buttons that are grouped and depending on your selection a data field is auto populated from the data in another field. The field that is auto populated is part of a simple yet complex formula to solve an equation, where some of the data is recycled. I had it working for the most part at some point today, just the last equation was kicking out the wrong answer. For example; the last equation would be something like .035x100=3.5%; but was giving the answer of 350%. I saved my progress even though the equation wasn't correct and when I opened it again to work out the issues, nothing worked anymore. I can get the radio buttons to autofill correctly but, that's it. Please help!?!?!

 

I attached the form and a couple of screen shots. Right under "Remarks" on Page 2 is the formula. Can someone please tell me what I'm doing wrong??Screen Shot Reference - Copy.jpgReference 2 - Copy.png

TOPICS
Create PDFs , Edit and convert PDFs , How to , JavaScript , PDF , PDF forms
766
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 ,
Jan 15, 2025 Jan 15, 2025

There's an error in your Difference field.  Group1 instead of this.getField("Group1").value, twice.

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 ,
Jan 23, 2025 Jan 23, 2025

Thank You for the speedy response!!!! Sorry it took me a minute to respond. Could you please elaborate on that?? I changed it to the script below but, it's still not working and I'm betting it's because I'm not even close. What am I missing here?

 

 

var a = this.getField("Group1").valueAsString;
if (Group1=="Choice1")
event.value = ("RunTicket").value -("GSV").value
else if (Group1=="Choice2")
event.value = ("RunTicket").value -("NSV").value

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 ,
Jan 23, 2025 Jan 23, 2025

You declared variable 'a' and you use Group1 instead of variable name:
if (Group1=="Choice1")

if (Group1=="Choice2")

it should be:

if (a=="Choice1") 

if (a=="Choice2")

 

Also in percentage field don't multiply by 100 to get 3.5% and pay attention to your field calculation order.

Another tip, since field "RunTicket1" have same value as "RunTicket" just give both fields same name, "RunTicket".

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 ,
Jan 27, 2025 Jan 27, 2025

Thank  You!! I'll give that a shot.

As for the field calculation order, that's the formula. I understand order of operation, but most people forget that order of expression matters as well. The reason this formula is used is because the Government approved this method and it's a very simple formula to find the difference shown as a percentage. For my work, we can only use formulas and procedures approved by the Government unfortunatly. Thank You again!!!!

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 ,
Jan 27, 2025 Jan 27, 2025
LATEST

I think @Nesa Nurani is referring to this regarding field calculation order:

 

https://pdfautomationstation.substack.com/p/pdf-field-calculation-order-matters

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