# Calculation using script or CDML???

This topic is 8411 days old. Please don't post here. Open a new topic instead.

## Recommended Posts

Hi, I have a field called quantity and a form on the web where a user can remove or add a certain quantity of the record using an input form. Supposing I have the recID, how do I update this? I don't want to edit it cause that will replace the value. Do I use a script when they click the submit button?

##### Share on other sites

Ohhhh...I'm getting vibes from the FMP Psychic Hotline...its saying you need to use calculation fields to accomplish the calc CaptKurt tried to explained to you in a post under 'Scripting'...

quote:

Simply make your TOTAL field a calculation, like the following: TOTAL = VALUE - ADJUSTMENT.

I'm assuming you plan to have multiple records for the same 'Item', something like several orders that will be subtracted from the original amount. There are lots of ways to do what you want. Below is a 'simple to understand' solution using two databases (DB_A and DB_:

DB_A has the following fields:

"Item Number" - a unique number designating the item - basis of relationship to DB_B.

"Item Description" - description of the item.

"Quantity" - number field where you input the starting quantity.

"SUMAdd" - a calculated field using the Sum function and the 'Add' field from DB_B .

"SUMRemove" - a calculated field using the Sum function and the 'Remove' field from DB_B.

"Total" - a calculated field where TOTAL = Quantity + SUMAdd - SUMRemove.

DB_B has these fields:

"ItemNumber" - Number to that matches an Item Number in DB_A.

"Remove" - a number field where you input the amount to remove.

"Add" - a number field where you input the amount to add.

"OrderNumber" - A unique number for this order.

"Person" - name of the person, or any other identifying fields so you know whose order this is.

On the HTML page, use related fields (i.e., [FMP-Field:DatabaseA::Quantity]) to display the original Quantity, Remaining Quantity, etc. from DB_A. Users would create or edit the record in DB_B, entering a number in the Add or Remove field on the HTML page. A new or edited record would be done using Submit Form.

If you have questions about these fields, about setting up relationships, etc., USE YOUR FMP HELP BUTTON to learn more - in particular, you'll want to learn the difference between a summary field and the Sum function. The built-in FMP help feature is pretty good for basics. ;-)

[ July 13, 2001: Message edited by: MeltDown ]

##### Share on other sites

This topic is 8411 days old. Please don't post here. Open a new topic instead.

## Create an account

Register a new account