Can Typeform do calculations on the parameters it's passed? | Community
Skip to main content
Answered

Can Typeform do calculations on the parameters it's passed?

  • February 12, 2023
  • 2 replies
  • 63 views

Can Typeform take a URL parameter (price, in this case) and compute the tip (based on a percentage) within the button selection? 

So if the price passed is 117.20 (p=117.20), then the button options would display the tip? 

Best answer by john.desborough

@Liz @teamsupport  - since the parameters passed in the URL are character strings, you can’t ‘add’ a character string into a calculation… 

however, if you have some standard ‘rates’ you have for the cleaning services ie 75, 100, 150 and pass these as variables in the url, you could use logic rules to create the underlying v_price (my name for the variable) and then do the calculations - ie:

  • if url parameter is client-price=100 then replace v_price with 100 
    • this looks at the character string inside the client-price hidden variable being passed and then sets the numeric variable v_price with value
  • on the tip question:
    • if q1 = b then multiply v_price by 1.15 (includes the tip percentage) 

now v_price should give you the total value that you can a) bill using stripe or b) show to the user in the ending

 

des

View original

2 replies

Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 15018 replies
  • February 13, 2023

Hi @teamsupport Happy Monday! This is a cool usage of Typeform. ðŸ˜€

I don’t believe this is possible using hidden fields since are text-based. I tried this on a form, but I couldn’t quite figure out a way to go about this. Possibly @john.desborough has seen a solution for this? 


john.desborough
Forum|alt.badge.img+6
  • Certified Partner & Champion
  • 5307 replies
  • Answer
  • February 13, 2023

@Liz @teamsupport  - since the parameters passed in the URL are character strings, you can’t ‘add’ a character string into a calculation… 

however, if you have some standard ‘rates’ you have for the cleaning services ie 75, 100, 150 and pass these as variables in the url, you could use logic rules to create the underlying v_price (my name for the variable) and then do the calculations - ie:

  • if url parameter is client-price=100 then replace v_price with 100 
    • this looks at the character string inside the client-price hidden variable being passed and then sets the numeric variable v_price with value
  • on the tip question:
    • if q1 = b then multiply v_price by 1.15 (includes the tip percentage) 

now v_price should give you the total value that you can a) bill using stripe or b) show to the user in the ending

 

des


Reply