Title: Predefined Value
Last modified: September 14, 2024

---

# Predefined Value

 *  Resolved [mate2001](https://wordpress.org/support/users/mate2001/)
 * (@mate2001)
 * [1 year, 8 months ago](https://wordpress.org/support/topic/predefined-value-2/)
 * Hello,
   I have the following problem. I want to display the result of a calculation
   in a number field.
 * If I set the field name under Predefined Value (fieldname1), it does not work.
   Presumably because it is the result of a calculation. So I tried this: getField(
   2).setVal(fieldname1|r);. This works perfectly. However, the user cannot overwrite
   this number in the frontend.
 * Example: The result 5 is automatically entered in the number field. In the frontend,
   however, the user wants to change this number to 7. This is not possible. It 
   always jumps back to 5, so it cannot be overwritten. Basically, the number field
   is then useless for me. I could display the result straight away.
 * So, how can I display the value of a calculation in the Predefined Value area
   AND make the value overwritable in the frontend?
 * Thank you for your help.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [1 year, 8 months ago](https://wordpress.org/support/topic/predefined-value-2/#post-18014761)
 * Hello [@mate2001](https://wordpress.org/support/users/mate2001/)
 * Thank you very much for using our plugin.
 * In short, you have an equation, for example, fieldname123+fieldname456, and you
   want to assign its result to another field in the form, the number field fieldname1,
   but you want to do it only the first time when the fieldname1 field is empty.
 * In this hypothetical case, you can implement the equation in the calculated field
   as follows:
 *     ```wp-block-code
       (function(){let result = fieldname123+fieldname456;let f = getField(fieldname1|n);if(f.val(true, true) == '') f.setVal(result);return result;})()
       ```
   
 * Best regards.
 *  Thread Starter [mate2001](https://wordpress.org/support/users/mate2001/)
 * (@mate2001)
 * [1 year, 8 months ago](https://wordpress.org/support/topic/predefined-value-2/#post-18014767)
 * You can’t imagine how happy I am. Great, that works. Thank you very much!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Predefined Value’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [mate2001](https://wordpress.org/support/users/mate2001/)
 * Last activity: [1 year, 8 months ago](https://wordpress.org/support/topic/predefined-value-2/#post-18014767)
 * Status: resolved