# smart-forms/0.5/js/formBuilder/formula/formula.js

Smart Forms – when you need more than just a contact form, version 0.5. 25 lines.

- Page: https://pluginprobe.com/plugins/smart-forms/0.5/code/js/formBuilder/formula/formula.js
- Raw: https://pluginprobe.com/plugins/smart-forms/0.5/raw/js/formBuilder/formula/formula.js
- Modified: 2013-12-16T00:14:28+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/smart-forms/0.5/code/js/formBuilder/formula/formula.js#L10-L20`.

```javascript
function RedNaoFormula(formElement,formula)
{
    this.FormElement=formElement;
    this.Formula=formula;
}

RedNaoFormula.prototype.FieldUsedInFormula=function(fieldName)
{
    for(var i=0;i<this.Formula.FieldsUsed.length;i++)
    {
        if(fieldName==this.Formula.FieldsUsed[i])
            return true;
    }

    return false;
}

RedNaoFormula.prototype.UpdateFieldWithValue=function(value)
{
    var calculatedValue=eval(this.Formula.CompiledFormula)(value);
    if(typeof calculatedValue=='number'&&isNaN(calculatedValue))
        calculatedValue=0;
    RedNaoBasicManipulatorInstance.SetValue(this.FormElement.Options,this.Formula.PropertyName,calculatedValue,this.Formula.additionalInformation);
    this.FormElement.RefreshElement();
}
```
