Answered

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

  • 12 February 2023
  • 2 replies
  • 46 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? 

icon

Best answer by john.desborough 13 February 2023, 18:21

View original

2 replies

Userlevel 7
Badge +5

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? 

Userlevel 7
Badge +6

@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