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

Acrobat form calculation - javascript help required

Community Beginner ,
Oct 09, 2020 Oct 09, 2020

This form currently calculates contract value as price per m2 x floor area

but it needs to be:-

Price per m2 x floor area x minimum hire period

(The minimum hire period being 52)

 

Eg. Boarding accommodation of 5000 m2 should come out at £1,950,000 – £2,080,000

 

I have uploaded the file with notes showing current javascript code.

https://documentcloud.adobe.com/link/review?uri=urn:aaid:scds:US:8bb7fcab-2b3d-4a05-a8ca-309d5b234ba...

 

Any help much appreciated. I'm a Javascript novice so please be gentle 🙂

TOPICS
PDF forms
851
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
2 ACCEPTED SOLUTIONS
Community Expert ,
Oct 09, 2020 Oct 09, 2020

Try to replace code in "requirements 15" field with the code below and see if that helps you:


var req1 = Number(this.getField("requirements 14").valueAsString);
var req2 = Number(this.getField("requirements 25").valueAsString);
var area = Number(this.getField("Floor Area").valueAsString);
var c1 = area*req1*52;
var c2 = area*req2*52;
event.value = util.printf("£%,0.0f",c1) + " - " + util.printf("£%,0.0f",c2);

View solution in original post

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 ,
Oct 21, 2020 Oct 21, 2020

Hi, see if this is what you looking for:

https://drive.google.com/uc?export=download&id=1cGudHlsipTtnWlN5sETXoNjPs55QbNkB 

I also input space in "Contract value" field between currency simbol so all fields with currency now look same.

View solution in original post

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 ,
Oct 09, 2020 Oct 09, 2020

Try to replace code in "requirements 15" field with the code below and see if that helps you:


var req1 = Number(this.getField("requirements 14").valueAsString);
var req2 = Number(this.getField("requirements 25").valueAsString);
var area = Number(this.getField("Floor Area").valueAsString);
var c1 = area*req1*52;
var c2 = area*req2*52;
event.value = util.printf("£%,0.0f",c1) + " - " + util.printf("£%,0.0f",c2);

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 Beginner ,
Oct 09, 2020 Oct 09, 2020

Hey. Nesa

Just tried that and it works perfectly. What a legend!

Thank you so much!!!

🙂

 

 

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 Beginner ,
Oct 21, 2020 Oct 21, 2020

Hi Nesa. Just when I thought this job was complete I have been asked to add two more fields 😞

Is it possible to expand the Javascript so that the floor area populates the delivery and installation and foundations fields? Both are based on floor area:-

 

Delivery calculation should be Floor area x 65 in £'s 

Foundation calalculation should be Floor area x 70 in £'s

 

PDF here

https://documentcloud.adobe.com/link/review?uri=urn:aaid:scds:US:ca64f14d-6422-451f-9038-cd43a6ae060...

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 ,
Oct 21, 2020 Oct 21, 2020

Hi, see if this is what you looking for:

https://drive.google.com/uc?export=download&id=1cGudHlsipTtnWlN5sETXoNjPs55QbNkB 

I also input space in "Contract value" field between currency simbol so all fields with currency now look same.

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 Beginner ,
Oct 21, 2020 Oct 21, 2020
LATEST

Oh that's amazing. I can't thank you enough for your help on this. 

 

 

 

 

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