SyntaxError: Missing; before statement

if ( qty1 < 1 ) then
Line Tot1 = unit price1;
if ( qty1 > 1 ) then
Line tot1 = unit price1 * Qty1;

can you tell me what is missing?

Karen Hargrove

6 Answers

How are you creating your form, Acrobat or LiveCycle?

What language are you trying to code in?

Where are you putting this code?

George Kaiser   

I am using Adobe Acrobat 10. I have a requistion form that needs to calculate a total when the qty orderd is 0, or if greater thean 0, multiple the qty by the unit price

Karen Hargrove   

I am using the Adobe Acrobat JavaScript Editor

Karen Hargrove   

It looks like you are trying to code either FormCalc in LiveCycle designer or trying to use FormCalc in the Simplified Field Notation calculation.

You need to code a custom JavaScript calculation for the "Line tot1" field using JavaScript:

if ( this.getFeidl("qty1").value < 1 ) {
event.value  = thsi.getField("unit price1").value;
if (this.getField("qty1").value  > 1 ) {
event.value = this.getField(:unit price1").value * this.getField("Qty1").value;

What happens when the qty1 field equals 1? What happens when the qty1 field is 0?

Are there other rows? If so you could write the code to be simpler or to compute what row and the field names for that row to process.

George Kaiser   

What happens when the qty1 field equals 1? it should be multiped by the unit price

Karen Hargrove   

You can use the following scripts:

// document or page open scripts - common code repeatedlly used in calculations;
function GetField(cField) {
// get field object for field named cField;
var oField = this.getField(cField);
if(oField == null) {
app.alert("Error getting units field \"" + cField + ".\"\nPlease check the field's name spelling and capitalization!", 1, 0);
return oField; // return field objec to null;
} // end GetField function

function ExtendPrice(cUnits, cPrice) {
// extend the units field * price field and return the result;
if(typeof GetField == "undefined") app.alert("You need to install the \"GetField\" function!", 1, 0);
// get the field objects and report any error;
var oUnits = GetField(cUnits);
var oPrice = GetField(cPrice);
if(oUnits != null && oPrice != null) {
// have good field objects - computed extended value;
var nUnits = oUnits.value; // get units value;
if(nUnits < 1) nUnits = Math.ceil(nUnits); // round units less than 1 to 1;
var nPrice = oPrice.value; // get the price value;
return nUnits * nPrice; // return extended result;
} else {
return "";
} // end invalid data;
} // end ExtendPrice function
// end document level funcitons;

The for the custom calculation for the the "Line Tot#" field for each row;

// custom calculation for "qty#" and "unit price#" where # is the row number
var nRow = 1;
if(typeof ExtendPrice == "undefined") app.alert("You need to install the \"ExtendPrice\" function!", 1, 0);
event.value = ExtendPrice("qty" + nRow, "unit price" + nRow);
// end custom calculation script;

Note that an error in the field name will cause an alert to appear that the field was not found and you need to check the spelling and capitalization of the field name. The scripts will also report if you are missing any of the required functions.

George Kaiser   

Please specify a reason: