Copy link to clipboard
Copied
New Issue
I have 3 fields SG1 NG1 EG1 The simple calculation is EG1=NG1+SG1
I am trying to accomplish two objectives
If NG1 is blank EG1 should be blank
If NG1 not blank EG1=NG1+SG1
I have tried several things and the closest I can get is to place the math formula in the NG1 validate field, but the closest I can get always adds the Starting Value of NG1 +SG1 even when I update NG1. It never adds the update value,
Also any one recommend any videos that explain java script for adobe pasr this, which is the most complicated script I have accomplishe with out help?
var level=this.getField("SL1").value;
if(event.target.value!="Off")this.getField("EL1").value=level+1;
if(event.target.value=="Off")
this.getField("EL1").value=level;
Copy link to clipboard
Copied
Don't use calculations in validations.
Use this as 'custom calculation script' of "EG1" field:
var a = Number(this.getField("NG1").value);
var b = Number(this.getField("SG1").value);
if(this.getField("NG1").valueAsString == "")
event.value = "";
else
event.value = a+b;
You writed if "NG1" is not blank EG1=NG1+SG1, so why you used 'level+1' in your script?
Copy link to clipboard
Copied
Are you using checkboxes?
If not, why are you using "if (event.target.value !="Off")"? The ON or OFF state corresponds to widgets, such as radio buttons or checkboxes.
Text field objects don't use this property, instead it should read 'if (event.target.value !="")' . Using the double quotes("") to declare a blanl value.
Also, please clarify exactly the name of all the calculated field objects in your form. In your inquiry yuo mentioned that you have 3 fields SG1 NG1 EG1. But then in your script you have different field names.
Copy link to clipboard
Copied
It was a two part question, the first dealing with those three fields.
The second showing my level oof incompitence and wanting to learn more and asking if anyone had advice on where I could learn more, I am use to c# and visual basic, so this is all new to me.
Copy link to clipboard
Copied
Don't use calculations in validations.
Use this as 'custom calculation script' of "EG1" field:
var a = Number(this.getField("NG1").value);
var b = Number(this.getField("SG1").value);
if(this.getField("NG1").valueAsString == "")
event.value = "";
else
event.value = a+b;
You writed if "NG1" is not blank EG1=NG1+SG1, so why you used 'level+1' in your script?
Copy link to clipboard
Copied
Different Script, Just demonstrating my limits so far.

