Community > Discussions
57 views
2 replies

Rounding up to predefined values in Live Forms

We have a use case where the user enters a measurement that is to be used as part of a calculation to determine cost but the product is costed out in increments of 5cm

for example 

0-5 should be rounded up to 5
5.01-10 should be rounded up to 10

 

eg adjusted width x cost = total cost

 2.75cm rounds to 5 x cost = total cost

anyone have any thoughts on how best to perform this with Live Forms

Bryan Bryan
Published 01/18/2021 21:00
Add Comment
Ashish Pachori

You can achive it by JavaScript action of Live Forms (Manage > Options > Actions > On Form View > Bind or update a single form field via JavaScript)

See https://www.mandeeps.com/support/knowledgebase/live-forms-actions-on-form-view-calculated-fields

replied 01/19/2021 10:11
Bryan

Thanks Ashish, appreciate you pointing me in the right direction here.

 

For anyone else looking for the solution here is what we actually implemented.

under Actions > On Form View we implemented the following:

(Math.ceil([Width in mm]/50)*50)

the Math.ceil function will round up to the nearest whole number so what we are effectively doing is divided by 50, then rounding up to the nearest whole number and then multiplying by 50 to get us the final answer. 

I hope this helps someone else.

 

 

 

 

replied 02/16/2021 01:24

Last Activity 02/16/2021 01:24