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

Javascript add (sum) and multiply?

smilem
Registered: Apr 1 2008
Posts: 101

But how can I add, multiply?

var xAxis = TextField3.rawValue + TextField5.rawValue
TextField4.rawValue = String.concat(xAxis, DropDownList1.rawValue)

var xAxis = (TextField3.rawValue * (TextField5.rawValue * 2))
TextField4.rawValue = String.concat(xAxis, DropDownList1.rawValue)

I cant use formcalc because my button has code that needs to use javascript

DropDownList1 - is mm, cm, in
TextField - is numeric data

My Product Information:
LiveCycle Designer, Windows
smilem
Registered: Apr 1 2008
Posts: 101
Anyone?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Concat is not the addition operator, '+'.
var xAxis = TextField3.rawValue * TextField5.rawValue * 2TextField4.rawValue = xAxis +  DropDownList1.rawValue

George Kaiser

smilem
Registered: Apr 1 2008
Posts: 101
I used concat to make output like

45cm or 10mm

The script can't calculate if I pass data like 10cm + 2cm
So the result is made by calculating and adding sufix using data from DropDownList1
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You are trying to pass a character string and not a numeric value. The use of 'cm' forces the values to character string. If you need to include the measurement unit, you will need to perform a lot more work to identify the measurement unit, convert them all to a common unit, and convert the string to a numeric value. You should only be entering numbers.

I would also format the fields as numbers or you will have to add additional code to make sure your are only processing numeric values and having to deal with invalid entries.

George Kaiser

jonom
Registered: Jan 31 2008
Posts: 133
smilem wrote:
I cant use formcalc because my button has code that needs to use javascript
If the code is on different events you can mix script languages.
smilem
Registered: Apr 1 2008
Posts: 101
The code is on print button preprint event.

I have positioning code and the coordinates are taken from textfields. The textfields are positioned from what user enters into textfields.

Let me explain what I'm trying to do. As you see from my code:

var xAxis = TextField6.rawValue
TextField2.rawValue = String.concat(xAxis, DropDownList1.rawValue)

The user enters numbers only into textfield6 this data is placed into variable xAxis
then another textfield2 is repositioned by the number and units (mm,cm, in) are added to it by concat from DropDownList1

The code is actually:

var xAxis = TextField6.rawValue
TextField1-1.x = String.concat(xAxis, DropDownList1.rawValue)

I was just testing with above code if the values are passed and if calculation works.

I can't use numberfields because the TextField1-1.x is expecting a number and another part is added using concat.

I just can't seem to find a way to (sum, multiply) in javascript as adobe manual list none as commands for javascript.

I need for example to:

var xAxis = (TextField3.rawValue + (TextField5.rawValue * 2))