This code creates a calculator for websites. It uses a custom formula to figure out a value based on what users type into different input fields.
Make it with Workshop
Build your own component with AI
This code creates a calculator for websites. It uses a custom formula to figure out a value based on what users type into different input fields. The formula can do simple math and make choices based on conditions. The tool updates the result whenever users change their inputs. It can show the calculated value and, if needed, extra information to help fix any problems. This calculator is flexible and can be used for various purposes on a website.
This component a part of the 400+ components, layouts, templates, UI Kits and code overrides from SegmentUI PRO. Click here to see the full library
Remember the "Name" of each form field
Use the "Name" to make conditional and variable formulas
Use debug=on to debug variables
Use the existing templates as a base to make calculations
The Formula control allows you to define the calculation logic used by the Project Value Calculator. You can create complex formulas using conditional statements and variables. For example:
Basic Calculation:
Formula: pages * 1000
Explanation: This formula multiplies the number of pages (input field named pages) by 1000. If you enter 5 in the pages field, the calculated value will be 5000.
Conditional Calculation:
Formula: if (complexity === 'Easy') { pages 500 } else { pages 1000 }
Explanation: This formula checks the value of the complexity field. If the complexity is 'Easy,' it multiplies the number of pages by 500; otherwise, it multiplies them by 1000. For example, if you select 'Easy' and enter 4 pages, the value will be 2000.
Nested Conditions:
Formula: if (type === 'Web') { if (complexity === 'Easy') { pages 1000 } else { pages 2000 } } else if (type === 'Mobile') { if (complexity === 'Easy') { pages 100 } else { pages 200 } } else { 0 }
Explanation: This more complex formula first checks the type of project (Web or Mobile). If it's a web project, it further checks the complexity and calculates the value accordingly. For instance, a 'Web' project with 'Easy' complexity and 3 pages would yield a value of 3000.
For any queries and help setting up the component, contact hello@segmentui.com
If a component does not function as advertised and the issue cannot be resolved, you are eligible for a full refund under our quality guarantee. Refunds will not be provided for any other reasons, including change of mind, accidental purchase, lack of use, or expectations of features not explicitly advertised.