Page 1 of 1

Help with Form Calculations not working

Posted: Mon Dec 09, 2024 11:36 pm
by rongreen
I could use some help. I cannot seem to get the field In-StockSubTot (name:InStockSubTotal) to total. The formula in its condition box is set to:

Number([InStockItem1Subtot])+Number([InStockItem2Subtot])+Number([InStockItem3Subtot]) with the target set to InStockSubTotal. I tried putting it in InStockItem1Subtot, InStockItem2Subtot, and InStockItem3Subtot with same results, not calculation happening. What am I doing wrong? Thanks for the help.



https://www.greensphotoimages.com/alljo ... lation.zip

Re: Help with Form Calculations not working

Posted: Tue Dec 10, 2024 7:26 am
by Pablo
Can you please remove everything from the page that is not relevant to your question, so I do not have to go through the settings of dozens of items? Otherwise it will take me a lot of extra time to try to help.

For further details about how to share a project file, please see this FAQ:
viewtopic.php?f=10&t=82134

Re: Help with Form Calculations not working

Posted: Tue Dec 10, 2024 5:00 pm
by rongreen
As requested, I stripped the form fields and grids that were not relevant and reattached the updated project.

In the interim, my wife and I kept working at it and did make some progress. However we would appreciate your looking at and providing input on our approach and critiquing it. I suspect our choice was not the best or optimal one. We did try putting a formula in the InStockItem1Subtotadding field summing all three subtotal fields, but could not get it to work. Not sure why? So we have two requests:

1) Help with the formula in terms of where it should actually go and if we wanted to put it into the first subtotal field what it should look like?
Here is what we used that worked: Number([InStockItem1DropDown])+Number([InStockChainLen1])+Number([InStockItem2DropDown])+Number([InStockChainLen2])+Number([InStockItem3DropDown])+Number([InStockChainLen3])

2) What do we need to do to end up with a number that is limited to two decimals (e.g. $xx.xx)? Right now, certain selections end up with the In-Stock Subtotal populating a number that looks like 44.410000000000004.



https://www.greensphotoimages.com/alljo ... tionv2.zip

Re: Help with Form Calculations not working

Posted: Tue Dec 10, 2024 6:18 pm
by Pablo
Unfortunately I do not have too much free time to look into this because I am very busy preparing the release of the new version.
But keep in mind however that this is not specific to WWB, but JavaScript and programming in general.
All JavaScript that works in a normal HTML page, will also work in WWB.

Your formula seems to be correctly implemented.

In JavaScript you can round numbers with 'toFixed', as mentioned here:
https://www.wysiwygwebbuilder.com/conditions.html

Re: Help with Form Calculations not working

Posted: Tue Dec 10, 2024 7:48 pm
by rongreen
Thank you for taking time to look into my inquiry. Your response met out need. Looking forward to seeing what the future release offers.