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

Undefined variables

vgumtow
Registered: Oct 26 2009
Posts: 3
Answered

I have the following short script to create a custom dialog box.

var oDlg =
{
shRate:0,
initialize: function(dialog)
{
console.println("In init: this.shRate = "+this.shRate);
dialog.load({"shRateField":this.shRate});
},
commit: function(dialog)
{
var data = dialog.store();
var testString = data["shRateField"];
console.println("In commit: testString is: "+testString);
this.shRate = parseFloat(testString);
console.println("In commit: this.shRate is: "+this.shRate);
var subtotal = getField("SubtotalField").value;
var shAmount = subtotal*((parseFloat(this.shRate))/100);
console.println("Shipping & Handling Rate is: "+this.shRate+" Shipping & Handling Amount is: "+shAmount);
},
description:
{
name: "Shipping & Handling Calculation Dialog",
elements:
[
{
type:"view",
elements:
[
{
name:"Enter Shipping & Handling Rate(%):",
type:"static_text",
},
{
item_id:"shRateField",
type:"edit_text",
char_width:10
},
{
type:"ok_cancel",
},
]
}
]
}
};

//Dialog Activation
app.execDialog(oDlg);

I get the following result on the console:

In init: this.shRate = 0
In commit: testString is: undefined
In commit: this.shRate is: NaN
Shipping & Handling Rate is: NaN Shipping & Handling Amount is: NaN

When I open the dialog box I type a value of 10 in the textfield name "shRateField".Can someone help me understand why when I hit "OK" I'm getting "undefined" as the value in this field? I'm running a trial version of Adobe Acrobat Pro 9.

Many thanks,

VG

My Product Information:
Acrobat Pro 9.2, Windows
vgumtow
Registered: Oct 26 2009
Posts: 3
Never mind. I got it to work! Many thanks anyway.
StampKing
Registered: Mar 18 2010
Posts: 3
Hello,

I have the same problem, how did you fix this?

Thanks