# Multiplying TextBoxField Values with JavaScript Actions and RadPdfProcessing

## Environment

| Version | Product          | Author                                                                          |
| ------- | ---------------- | ------------------------------------------------------------------------------- |
| Q4 2024 | RadPdfProcessing | [Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova) |

## Description

This article shows how to create a PDF document with three [TextBoxFields](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/annotations/widgets) where the third field multiplies the values of the first two widgets.

## Solution

Use the [JavaScript Actions](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/actions/js-actions/javascript-actions) feature introduced in Q4 2024 for the RadPdfProcessing library:

**Example 1: Multiply Two TextBoxField Values with a JavaScript Action**

```csharp
RadFixedDocument document = new RadFixedDocument();
document.Pages.AddPage();

TextBoxField priceField = new TextBoxField("Price");
priceField.Value = "12";
priceField.IsReadOnly = true;
VariableContentWidget priceWidget = priceField.Widgets.AddWidget();
priceWidget.Rect = new Rect(new Size(150, 30));

TextBoxField amountField = new TextBoxField("Amount");
VariableContentWidget amountWidget = amountField.Widgets.AddWidget();
amountWidget.Rect = new Rect(new Point(0, 50), new Size(150, 30));

TextBoxField totalField = new TextBoxField("Total");
totalField.IsReadOnly = true;
totalField.Actions.Calculate = new Telerik.Windows.Documents.Fixed.Model.Actions.JavaScriptAction
    ("AFSimple_Calculate(\"PRD\", new Array (\"Amount\", \"Price\"));");
VariableContentWidget totalWidget = totalField.Widgets.AddWidget();
totalWidget.Rect = new Rect(new Point(0, 100), new Size(150, 30));

document.AcroForm.FormFields.Add(priceField);
document.AcroForm.FormFields.Add(amountField);
document.AcroForm.FormFields.Add(totalField);
document.Pages[0].Annotations.Add(priceWidget);
document.Pages[0].Annotations.Add(amountWidget);
document.Pages[0].Annotations.Add(totalWidget);
```

The following image shows the result:

![JS Action Multiply FormField](https://www.telerik.com/document-processing-libraries/documentation/assets/3403c1d44d31f53c09d9497928464adb/js-action-multiply-form-field.gif)

## See Also

* [Interactive Forms](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/overview)
* [JavaScript Actions](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/actions/js-actions/javascript-actions)
