Streaming live at 10am (PST)

Doing math on a CMS page?

Hello,

I want to create a “math” interaction in a website I am creating, I came up with this formula:

0.77*(3000n) + 1000n*m
n= Modifier imputed in the CMS by me. (I assume I input it as an integer?)
m= Modifier picked by a visitor of the website by a dropdown on the specific CMS page.

using CMS because it is a collection and each item in the collection has a different n.

I need to be able to show the correct item on each CMS page, what is the smoothest way to achieve that in webflow?


Here is my public share link: LINK
(how to access public share link)

Or even something as simple as just converting hours into days:
n/24

n=number of hours

I don’t know what you’re trying to achieve exactly, but soetimes you can use CSS Calc along with CMS or fixed variables.

Something like: `width:calc(100vh-60px)``

https://www.w3schools.com/cssref/func_calc.asp

Hey @vincent , thank you for the reply. Will try to explain better

I want a number to appear inside a DIV (inside a CMS page) - the number is the final price that the client sees after the calculation is being done in the backend

This is an example formula: 0.77*(3000n) + 1000n*m
n= Is a value that is unique to each of the CMS pages and imported when a CMS page is created. (Integer)
m= Is a value the client inputs inside an input box when they are on a spesific page

After the client entered the desired value a result will pop up that will be the result of the calculation. - I am a designer natively so it is hard for me to figure out how to put in this functionality

@Artur_Butvilovsky, what would be the reason for just the client to do this? Why would these values need to be placed on a website?

I am missing something at the direction of your intended results?

Can you please provide a share link of your project so we may see what your desired outcome is supposed to be?

TIA and Happy Designing,
Brandon

@WebDev_Brandon
When saying client - I ment website visitors - The websites goal is to sell offline courses.
n= base price of each course (which is inputed in the CMS - each course has it’s own CMS page)
m= the number of participants a visitor would like to check the price for (default 1 participant)

and then the visitor of the website can see the price after inputing the desired m.

The website is still in beginning phases, just trying to figure out how to do this first

@Artur_Butvilovsky have you though about using Memberstack.io for this such function. You are able to create secure backends, etc.

Reach out to @DuncanHamra for any additional help!

1 Like

Maybe I have missunderstood, but from quick view at that website - it looks like a membership integration - which the website doesn’t require.
All I need is to make a custom math functionality that takes inputs from the CMS page and visitor input - any website visitor should be able to do it.

@Artur_Butvilovsky I would then refer to the post that @vincent posted above.

This requires custom code. You can use the values of CMS fields in calculations and then display the results via custom code on your CMS page.

1 Like

Thank you for the reply - I was hoping someone could explain to me or show an example of how to do this if it exists somewhere - I am natively a designer who slowly learns code while using webflow, so I have no idea how to start working around this :slight_smile:

Hello @Artur_Butvilovsky,

You can use the embed block to add a calculator from calconic. All you have to do is add an embed block on your site and copy and paste the code you get from calconic.com. Here is a youtube link on how to do it https://www.youtube.com/watch?v=_BFqx2k9QxA I hope this puts you on the right track.

1 Like

This is nice for calculators, but i think it’s just another 3rd party (paid) license thing, which should not be needed.

I also have many situations in where i need to calculate some things.
For example:

  • i want to show a total number of collection items in a collection list and just count + show this number live on the website (f.e. "we have xx news items ")
  • i want to add up all the numbers in a specific field, from all collection items, and show the sum of this as a real number on the website. (f.e. " we delivered xxxx kWh power in all our solar-projects combined")
  • i would also like some more advanced calculations like log/exp/sqrt stuff, but haven’t needed this much until now.