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

need help with Javascript

New Here ,
Apr 29, 2021 Apr 29, 2021

Copy link to clipboard

Copied

Full disclosure, I'm pretty new to Adobe PDF creation and I've been teaching myself via YouTube.  I've run into a wall and I'll try to explain this coherently.

 

I have a form that has a value [Base value].  [Base Value] is mirrored in another field. [Base value mirror].  I then have 3 check boxes with 2 associated fields.  [Final value] is = to [Base Value Mirror] IF a checkbox is checked.  If the checkbox is not checked, then [Final Value] is half of [Base Value Mirror] rounded down.  The other 2 check boxes are independant of everything but [Final Value].  Box 1 is +10% and Box 2 is +20%, both can be unchecked but only 1 can be checked, which is then added to [Final Value].

 

It seems complicated as all get out to me so if anyone can point me in the correct direction or give me some cluse, I would appreciate it.

TOPICS
How to , JavaScript , PDF forms

Views

659

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 ,
Apr 30, 2021 Apr 30, 2021

Copy link to clipboard

Copied

Hi, do you have any of the above work done or you need help with all of it?

When you say 10% or 20% , you mean of base value or final value after all calculations?

Can you post your file here?

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 ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

I have some of the very basic work done.  I apologize if I was unclear.  Getting my "thoughts" into how I want it to work is bothersome.  +10% or +20% after all calculations are done.  I attached the file so you can see what I'm trying to do.

 

Also, thank you very much for the help.

 

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 ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

There is lots of fields in that file, so you will need to be more specific at which fields exactly you want to calculate (name of the fields).

You have lots of duplicate fields, I'm not sure if thats on purpose,just so you know, when you have fields with same name, once you populate one of them all others will get same value also.

Here is basic script that should do what you ask, you will need to put ".10" and ".20" as export value of percentage checkboxes,of course you will have to adapt it with your fields names:

var c2 = 0;
if(this.getField("Check Box1").valueAsString != "Off")
var c1 = Number(this.getField("Base Value Mirror").value);
else c1 = this.getField("Base Value Mirror").value/2;
if(this.getField("Check Box2").valueAsString != "Off")
c2 = Number(this.getField("Check Box2").value);
event.value = c1*(1+c2);

Here is sample file with script in work:

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

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 ,
May 28, 2021 May 28, 2021

Copy link to clipboard

Copied

LATEST

First, thank you very much for your help as it is greatly appreciated. Secondly, your example is very helpful and almost exactly what I'm looking for.  Below, you can see that the "Base Value" under the coloumn "CHAR" for the S stat are the same (highlighted in red).  The "Total" is different because the "skill" is either checked or unchecked.  Checked is full value of CHAR, unchecked is half-value.  IF, Skill is checked (Taken column), then you can check either +10% or +20%, or not check either.  The 10%/20% is added to Total for a complete Value(?)

 

I hope I'm explaining myself correctly? I've been learning by trial and error, so if I'm using incorrect terminology please feel free to correct me.

FIelds 3.PNG

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