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

if then else not working for calculation

webmaster
Registered: Jan 26 2007
Posts: 8

Hi there, can't seem to get this to work. (Javascript newbie). Not using LiveCycle Designer.
 
Fields: SaturdayOnly (default value = 0), Number, and Amount
 
Want to calculate the cost (Field = Amount) based on the value of either SaturdayOnly and Number.
 
If SaturdayOnly is 0 then use the value in Number. If SaturdayOnly is not 0 then use the value in SaturdayOnly.
 
What I've done: Clicked on Amount field, on Calculate tab selected Custom calculation script. Entered the following script:
  
if (SaturdayOnly == 0)
{
Number*90;
}
else
{
SaturdayOnly*20;
}
 
Result: Enter a number in SaturdayOnly eg.2 and expect to see in Amount the value 40. Actual result: blank in Amount. Entered a number in Number eg. 1 and expect to see in Amount the value 90. Actual result: blank in Amount.
 
What am I missing?

My Product Information:
Acrobat Pro 9.4.2, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
That appears to be a snippet of the code.

Are you getting any errors in the JavaScript debugging console?

Can you post the whole script including the assigning of values to the variables.

Adobe Acrobat JavaScript is just like JavaScirpt, it is an object orientated language. You need to acquire the object before you can access any property of use any method of that object.

It appears you are trying to use some FormCalc syntax in an Acrobat form.

if (this.getField('SaturdayOnly').value == 0)
{
event.value = this.getFeild("Number").value * 90;
}
else
{
event.value = this.getField("SaturdayOnly").value * 20;
}

George Kaiser