Hi,
I have a field called lifeCharge and it is calculated from the value of two other fields, allPlans30 or allPlans35. The calculation can only come from one or the other. I have the default set at zero for allPlans30 and allPlans35. The calculation works fine, however, if I put an amount in field allPlans35 and tab out, it goes to the next field (allPlans30) and resets the amount in allPlans35. How do I prevent this from happening? Thanks!
Per Life Charge $____________
All Plans ($35 x ________0)
All Plans ($30 x ________0)
Script for allPlans35 in the exit event
if(this.rawValue != 0)
lifeCharge.rawValue = this.rawValue * 35;
allPlans30.rawValue = 0;
Script for allPlans30 in the exit event
if(this.rawValue != 0)
lifeCharge.rawValue = this.rawValue * 30;
allPlans35.rawValue = 0;
Views
Replies
Total Likes
I tried another approach - I removed the scripts from allPlans35 and allPlans30 fields and added the following script in the lifeCharge field as a calculation event.
if
(allPlans30.rawValue == 0 || allPlans30.rawValue == null)
this.rawValue
= allPlans35.rawValue * 35;
else
if (allPlans35.rawValue == 0 || allPlans35.rawValue == null)
this.rawValue
= allPlans30.rawValue * 30;
Now what is happening is if you enter an amount in allPlans35 and change your mind and enter an amount in allPlans30, you have to manually delete the amount in allPlans35 to have the calculation work. Is this the way is has to be or is there a better solution.
Thanks
Views
Replies
Total Likes
Hi,
There are a couple of approaches.
I am inclined to suggest the following javascript in the calculate event of the lifeCharge object:
this.rawValue = (allPlans35.rawValue * 35) + (allPlans30.rawValue * 30);
This is on the basis that the user can only place a value in allPlans35 OR allPlans30.
To achieve this have the following in the exit events:
allPlans 35 exit event:
if (this.rawValue != null) // allPlans35
{
allPlans30.rawValue = 0;
}
allPlans 30 exit event:
if (this.rawValue != null) // allPlans30
{
allPlans35.rawValue = 0;
}
Hope that helps,
Niall
Views
Replies
Total Likes
Hi Niall, thanks for your response. This does work if I mouse exit out of field allPlans35, however, if I keep tabbing it clears them.
Views
Replies
Total Likes
Hi,
I am going to suggest a FormCalc script for the two exit events:
// if this field has a value, then clear the other field
if (HasValue($) and $ ne 0) then
allPlans30.rawValue = 0
endif
Here is an example:
https://acrobat.com/#d=sTbpBqlVu6jFqqM7jvRG*A
Hope that helps,
Niall
Views
Replies
Total Likes
When I tab out of field allPlans35, it acts very slow and then when I tab out of field allPlans30 I get a Runtime Error and the form closes.
Views
Replies
Total Likes
I think I got it. I added the following script to the exit event of allPlans30 and allPlans35.
if
(this.rawValue != 0) //allPlans35
xfa.host.resetData("xfa.form.form1.allPlans30");
if
(this.rawValue != 0)//allPlans30
xfa.host.resetData("xfa.form.form1.allPlans35");
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies