These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Custom calculation script issue

adunn
Registered: Mar 10 2010
Posts: 4
Answered

I have created the below script. I can not get only either the first part of the second part to work. I can not get them both to work.

//TRAIL obtain the value for the field objects:
var MemberBlanketfee= this.getField( ' MemberBlanketfee ').value;
var TrailTotal= this.getField(' TrailTotal ').value;
var TrailClass = this.getField(' TrailClass ').value;
var MemberDailyFee = this.getField(' MemberDailyFee ').value;
// test the value of the check box
if (MemberBlanketfee == '85')
event.value = 0;
else
event.value = TrailClass * 12;

if (MemberDailyFee == '30')
event.value = 0;
else
event.value = TrailClass * 12;

My Product Information:
Acrobat Pro 9.0, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Are you getting any script errors?

Have you tired adding console statements to show what is going on?

What is not working?

Clearly explain what you are trying to acccomplish. You may have a error in the logic of your testing.
//TRAIL obtain the value for the field objects:var MemberBlanketfee = this.getField('MemberBlanketfee').value;var TrailTotal = this.getField('TrailTotal').value;var TrailClass = this.getField('TrailClass').value;var MemberDailyFee = this.getField('MemberDailyFee').value; // open javascript console for debuggingconsole.show(); console.clear();// show field values:console.println('Field values:')console.println('MemberBlanketfee: ' + MemberBlanketfee)console.println('TrailTotal: ' + TrailTotal)console.println('TrailClass: ' + TrailClass)console.println('MemberDailyFee: ' + MemberDailyFee)// results of logical tests:console.println('Logical test results:');console.println("if (MemberBlanketfee == 85) : " + (MemberBlanketfee == 85) );console.println("if (MemberDailyFee == 30) : " + (MemberDailyFee == 30) ); console.println('Action taken:'); // test the value of the check boxif (MemberBlanketfee == 85) {console.println('MemberBlanketfee')event.value = 0;}else {console.println('TrailClass * 12');event.value = TrailClass * 12;} if (MemberDailyFee == 30) {console.println('MemberDailyFee')event.value = 0;}else {console.println('TrailClass * 12');event.value = TrailClass * 12;} // assuming an or testconsole.println('');console.println('MemberBlanketfee or MemberDailyFee');if (MemberBlanketfee == 85 | MemberDailyFee == 30) {console.println('MemberDailyFee or MemberDailyFee - no charge')}else {console.println('TrailClass * 12: ' + TrailClass * 12);}

George Kaiser

try67
Expert
Registered: Oct 30 2008
Posts: 2399
Your second condition makes the first one moot. It doesn't matter what happens in the first part, because the second one will set event.value in any case.
You need to better define what it is you want to do.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

jimhealy
Team
Registered: Jan 2 2006
Posts: 146
This will always go through to:
if (MemberDailyFee == '30')
event.value = 0;
else
event.value = TrailClass * 12;

What you need is:
if (MemberBlanketfee == '85' || MemberDailyFee == '30')
event.value = 0;
else
event.value = TrailClass * 12;

Jim Healy
FormRouter, Inc.
Check out our FREE Advanced Acroform Toolset:
http://www.formrouter.com/tools

Jim Healy, Founder & CEO FormRouter Inc.
Chapter Leader AUG RTP NC
http://www.formrouter.com

adunn
Registered: Mar 10 2010
Posts: 4
Thanks Jim that worked great!!!