Copy link to clipboard
Copied
I wish to compare the values of two fields that are calculated based upon the sum of other fields like this:
sum1=fieldx +fieldy+fieldz
sum2=fielda+fieldb+fieldc
if sum1>sum2 then sum2 should display a 0 and if sum2 displays a 0, then fielda+fieldb+fieldc should become invisible only to the user, but still be there since it is a part of theabove equation. so far I have this, but this does not even insert 0 into the field
event.value=this.getField("2ea3").value>=event.value ? this.getField("2eD").value : 0;
In the above example I use 2ea3 for sum1 and 2eDfor sum2. When I run it in debugger, it does show a zeo but it does not insert it into the form. I don't know why it is not inserting a zero into the field when the debugger results to 0.
Thanks for your help.
If you use that code in "2eD" field, then how do you calculate sum2?
Also you write that you want to check if sum1>(is greater)sum2 but in your script you used sum1>=(is greater or equal)sum2 so I'm not sure which one you want so Il use > in my script and you change it if it's not correct.
See if this is what you looking for,put it in "2eD" field as custom calculation script and if your actual name for fielda,fieldb and fieldc are different then in script, change them to your actual names:
var a
...You can't manually input value into that field because calculation will overwrite your input, thats way field stay blank. For the other part, script is set so it stays blank until there is value in all four fields.
See if this script does what you want:
var a = this.getField("5a.0.4");
var b = this.getField("5a.1.4");
var c = this.getField("5a.2.4");
var d = this.getField("5b1");
var y = this.getField("2ea3").value;
var x = Number(a.value)+Number(b.value)+Number(c.value)+Number(d.value);
if(x != 0 &
...Copy link to clipboard
Copied
If you use that code in "2eD" field, then how do you calculate sum2?
Also you write that you want to check if sum1>(is greater)sum2 but in your script you used sum1>=(is greater or equal)sum2 so I'm not sure which one you want so Il use > in my script and you change it if it's not correct.
See if this is what you looking for,put it in "2eD" field as custom calculation script and if your actual name for fielda,fieldb and fieldc are different then in script, change them to your actual names:
var a = this.getField("fielda");
var b = this.getField("fieldb");
var c = this.getField("fieldc");
var y = this.getField("2ea3").value;
if(typeof a.value == 'string' || typeof b.value == 'string' || typeof c.value == 'string')
var x = "";
else
x = a.value+b.value+c.value;
if(x != "" && y>x){
event.value = 0;
a.display = display.hidden;
b.display = display.hidden;
c.display = display.hidden;}
else{
event.value = x;
a.display = display.visible;
b.display = display.visible;
c.display = display.visible;}
Copy link to clipboard
Copied
Thank you for answering my question. For the 2eD field, i used the built-in calculator under text field properties. I told Adobe to give me the sum of these actual field names (actual names in my form - 5a.0.4, 5a.1.4, 5a.2.4, 5b1. So 2eD = the sum of 5a.0.4, 5a.1.4, 5a.2.4, 5b1 I did not use any scripting for that. Does that matter? Will javascripting override calculated values in that way?
Copy link to clipboard
Copied
No, it doesn't matter. You just have to make sure the fields calculation order is correct.
Copy link to clipboard
Copied
I get a syntax err:sytax error
7;at line 8
var a = this.getField("5a.0.4");
var b = this.getField("5a.1.4");
var c = this.getField("5a.2.4");
var d = this.getField("5b1");
var y = this.getField("2ea3").value;
if(typeof a.value == 'string' || typeof b.value == 'string' || typeof c.value == 'string')|| typeof d.value == 'string'
var x =""; <------points here
else
x = a.value+b.value+c.value+d.value;
if(x != "" && y>=x){
event.value = 0;
a.display = display.hidden;
b.display = display.hidden;
c.display = display.hidden;}
else{
event.value = x;
a.display = display.visible;
b.display = display.visible;
c.display = display.visible;}
Copy link to clipboard
Copied
It's the line before that one. Your parentheses don't match... The entire condition in the if-statement has to be placed inside parentheses.
Copy link to clipboard
Copied
This seems to work but when I manual change the values, from the fields going invisible (I make it so y is less than x by changing the field numbers, the form does not seem to recalculate. The invisible fields that were supposed to become visible again do indeed become visible but they do not calcuate in the "2ea3" field (where they were adding the 4 fields before. They just stay zero. Is there like an f5 refresh butting in Adobe? I don't think there is. How do I "wake up" the form and tell it to recalcuate?
Copy link to clipboard
Copied
See the last part of my first reply.
Copy link to clipboard
Copied
I thought that was the issue but there are so many fields in that box. I do not know which to place in what order. What kind of fields do I prioritize?
Copy link to clipboard
Copied
I am stuck. I reordered the calculation order and I am still getting zero in the field that calculates the four fields above (a b c and d). The other summing fields calculate. It is just the field with the scripting that does not.
Copy link to clipboard
Copied
I figured out that there was a validation scrip that was causing a 0 to be entered in the box but now it is coming up blank. The four fields that need to be calculated under the above script yeilds a blank field and there is not even a zero in the box.
Copy link to clipboard
Copied
To further illustrate, this is what the field looks like. Look at line 2(e) D. It should have a number in there. You can actually type a number in there but it stays blank.
Copy link to clipboard
Copied
You can't manually input value into that field because calculation will overwrite your input, thats way field stay blank. For the other part, script is set so it stays blank until there is value in all four fields.
See if this script does what you want:
var a = this.getField("5a.0.4");
var b = this.getField("5a.1.4");
var c = this.getField("5a.2.4");
var d = this.getField("5b1");
var y = this.getField("2ea3").value;
var x = Number(a.value)+Number(b.value)+Number(c.value)+Number(d.value);
if(x != 0 && y>=x){
event.value = 0;
a.display = display.hidden;
b.display = display.hidden;
c.display = display.hidden;}
else{
event.value = x;
a.display = display.visible;
b.display = display.visible;
c.display = display.visible;}
Copy link to clipboard
Copied
Hi Nesa,
You can't manually input value into that field because calculation will overwrite your input,
It's not totally true. You have the possibility to overwrite a calculated field and the calculation will overwrite the input only if the event source comes from a field included in the calculation (understandable????). Else the overwritten value stays in place.
Please have a look on the attached example.
@+
Copy link to clipboard
Copied
You can't manually input value into that field because calculation will overwrite your input,
See the words in red? I belive she referring to the field where script is and script in it, so she is not saying it generally. My english is not that great I could be mistaken?
Copy link to clipboard
Copied
I will not argue about that because my English is certainly not quite good enough.
It was just information.
@+
Copy link to clipboard
Copied
Hey Nesa: First: Thank you for all your help. You are amazing.
I tried the script and it seems to work but I was wanting to blank out the 5b1 field as well in the priority debts (see picture line 2(e)(A)(3) exceeded or equalled the unsecured claims 2(e)(D). I also wanted to blank out var d ("5b1") which is unsecured claims later on in the plan document (see pic)
See 5(b) on the document (4th line down) and field 5b1). This should also become hidden because paying the priority claims (2(e)D on the form on the picture, eliminates the need to pay other unsecured creditors.
In case you are interested, this is for Chapter 13 cases in the Eastern District of PA.
So, should this:
var a = this.getField("5a.0.4");
var b = this.getField("5a.1.4");
var c = this.getField("5a.2.4");
var d = this.getField("5b1");
var y = this.getField("2ea3").value;
var x = Number(a.value)+Number(b.value)+Number(c.value)+Number(d.value);
if(x != 0 && y>=x){
event.value = 0;
a.display = display.hidden;
b.display = display.hidden;
c.display = display.hidden;}
else{
event.value = x;
a.display = display.visible;
b.display = display.visible;
c.display = display.visible;}
be this?
var a = this.getField("5a.0.4");
var b = this.getField("5a.1.4");
var c = this.getField("5a.2.4");
var d = this.getField("5b1");
var y = this.getField("2ea3").value;
var x = Number(a.value)+Number(b.value)+Number(c.value)+Number(d.value);
if(x != 0 && y>=x){
event.value = 0;
a.display = display.hidden;
b.display = display.hidden;
c.display = display.hidden;
d.display=display.hidden}
else{
event.value = x;
a.display = display.visible;
b.display = display.visible;
c.display = display.visible;
d.display = display.visible}
Copy link to clipboard
Copied
You removed this.
if(typeof a.value == 'string' || typeof b.value == 'string' || typeof c.value == 'string'|| typeof d.value == 'string')
what was the purpose of that in the first place? I am genuinely curious.
Copy link to clipboard
Copied
This is working pretty well. Thank you everyone and particularly Nesa!