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

Help coding

chrispegg
Registered: Nov 21 2009
Posts: 3

I have 2 fields in my PDF form that I need to link.

The field "ShirtType" is a drop down with 4 entries:

1) Short Sleeve Tee Shirt
2) Long Sleeve Tee Shirt
3) Crew Neck Sweat Shirt
4) Hooded Sweat Shirt

Based on the selection, the field "CostPerParticipant" should be filled in as follows:

If "ShirtType" = Short Sleeve Tee Shirt then "CostPerParticipant" = 100;
If "ShirtType" = Long Sleeve Tee Shirt then "CostPerParticipant" = 105;
If "ShirtType" = Crew Neck Sweat Shirt then "CostPerParticipant" = 110;
If "ShirtType" = Hooded Sweat Shirt then "CostPerParticipant" = 115

I have tried If-ElseIf statements and Case statements but am having no luck. Any help would be appreciated.

My Product Information:
Acrobat Pro 9.0, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2399
Are you sure you used the correct JavaScript syntax? If-ElseIf and Case are VB functions.
In JS you just have if/else and switch. Have a look here: http://w3schools.com/js/js_if_else.asp and here http://w3schools.com/js/js_switch.asp

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

chrispegg
Registered: Nov 21 2009
Posts: 3
I'm definately not sure. Just a novice at this This is the code I am using. It gives no syntax error, but it is not displaying a value in the 'CostPerParticipant' field. I'm sure I am missing something easy...

switch(ShirtType)
{
case(ShirtType)="Short Sleeve Tee Shirt":
CostPerParticipant=("100");
break;
case(ShirtType)="Long Sleeve Tee Shirt":
CostPerParticipant=("105");
break;
case(ShirtType)="Crew Neck Sweat Shirt":
CostPerParticipant=("110");
break;
case(ShirtType)="Hooded Sweat Shirt":
CostPerParticipant=("115");
}
revoxo
Registered: Jul 20 2009
Posts: 17
You need to refer to the Acrobat JavaScript Reference (http://www.adobe.com/devnet/acrobat/javascript.php), there's lots of code examples where you can get the correct syntax which why you're having problems.

Put this code into the Custom Calculation Script area for the "CostPerParticipant" field:

var shrtype = this.getField("ShirtType").value; //get the value of field "ShirtType"
var cpp = this.getField("CostPerParticipant"); //get the "CostPerParticipant" field object

switch(shrtype)
{
case "Short Sleeve Tee Shirt":
cpp.value = "100";
break;
case "Long Sleeve Tee Shirt":
cpp.value = "105";
break;
case "Crew Neck Sweat Shirt":
cpp.value = "110";
break;
case "Hooded Sweat Shirt":
cpp.value = "115";
break;
}