Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Field Calculations

Avatar

Level 1

Hi

   Very new to this, so please forgive me.  Need to know how to make a field calculation.  Have a Qty1 Numeric box and a Price1 numeric box.  Looking to multiply these and put the answer in Total1 Numeric box.  File is attached. Can't make it work.  Please help.  Thanks.

8 Replies

Avatar

Former Community Member

On the Calculate event of the Total field you can add the FORMCALC command:

Qty1

* Price1

In FormCalc the default property is the rawValue so by not naming a property or method you are getting the fields rawValue. Also the field that has focus will get the return value from the command (in this case the Total field). The calculate event will fire each time the value of Qty1 or Price1 changes.

If you woudl rather do it in Javascript the command woudl look like this:

this.rawValue = Qty1.rawValue * Price1.rawValue;

Hope that helps

Paul

Avatar

Level 1

Paul

Excuse my novice, but where would I put the formula? The binding tab, field tab or value tab? I had the formula correct, but have no idea where it goes. Please let me know and thanks for the help.

Date: Wed, 16 Sep 2009 07:43:28 -0600

From: forums@adobe.com

To: hwood71@hotmail.com

Subject: Field Calculations

On the Calculate event of the Total field you can add the FORMCALC command:

Qty1

  • Price1

In FormCalc the default property is the rawValue so by not naming a property or method you are getting the fields rawValue. Also the field that has focus will get the return value from the command (in this case the Total field). The calculate event will fire each time the value of Qty1 or Price1 changes.

If you woudl rather do it in Javascript the command woudl look like this:

this.rawValue = Qty1.rawValue * Price1.rawValue;

Hope that helps

Paul

>

Avatar

Former Community Member

Click on the field that will have the code on it (the Total field). Now you need to activate the Script editor if it is not enabled. Under Window make sure Script Editor is selected. It shodul be visible to you now ....it will appear between the drawing area and the toolbars by default. You may want to resize the drawing area to give yourself more room. There shoudl be a line of text there already (becaus eyou have chosen the total field). This indicates which field you are putting the code on and what event it is on. In the top right there is a dropdown entitled "Show". This is the list of events that is available for this object. Select Calculate. Now on the right side of the script editor make sure the Language is set to the appropriate value for your script (FormCalc or Javascript) and make sure the RunAt is set to client. Now paste the code below the previously mentioned line.

Now you are ready to test.

Paul

Avatar

Level 1

Paul

That didn't work and now it woun't open the file. it gives this error. I click ok and it closes and does nothing else.

Date: Wed, 16 Sep 2009 08:58:47 -0600

From: forums@adobe.com

To: hwood71@hotmail.com

Subject: Field Calculations

Click on the field that will have the code on it (the Total field). Now you need to activate the Script editor if it is not enabled. Under Window make sure Script Editor is selected. It shodul be visible to you now ....it will appear between the drawing area and the toolbars by default. You may want to resize the drawing area to give yourself more room. There shoudl be a line of text there already (becaus eyou have chosen the total field). This indicates which field you are putting the code on and what event it is on. In the top right there is a dropdown entitled "Show". This is the list of events that is available for this object. Select Calculate. Now on the right side of the script editor make sure the Language is set to the appropriate value for your script (FormCalc or Javascript) and make sure the RunAt is set to client. Now paste the code below the previously mentioned line.

Now you are ready to test.

Paul

>

Avatar

Former Community Member

What error ......I modified your original form and reattached it here with the code in it.

Paul

Avatar

Level 1

Paul

Didn't get an attachment. Did you get my attachment? I sent a word Doc with the error.

Date: Wed, 16 Sep 2009 11:29:08 -0600

From: forums@adobe.com

To: hwood71@hotmail.com

Subject: Field Calculations

What error ......I modified your original form and reattached it here with the code in it.

Paul

>

Avatar

Level 1

Paul

Disreguard the last email. Sorry

Date: Wed, 16 Sep 2009 11:29:08 -0600

From: forums@adobe.com

To: hwood71@hotmail.com

Subject: Field Calculations

What error ......I modified your original form and reattached it here with the code in it.

Paul

>

Avatar

Level 1

Paul

     Thank you so much.  I have learn so much from this.  The code is work great.  Now I just need to figure out how top do a grand total field.  Thanks again you're great.