Field Calculations | Community
Skip to main content
Level 2
July 22, 2015
Solved

Field Calculations

  • July 22, 2015
  • 1 reply
  • 7778 views

Is it possible for a customer to enter data into one or two fields and have a third field calculate the value and immediately display for the customer to see?

For example:

Lot Size: 1000 Sq. Ft.

Salt melt area: 1 bag/500sq. ft

Bags of Salt  Needed: 2 bags

So the calculated value will be the Bags of Salt, but the first entry is all that is needed.  The Salt Melt area will be a default hidden value stored in the field.

Thanks everyone!

Best answer by SanfordWhiteman

JS has all the built-in math functions you need.

Here's a naive implementation of what you're talking about: MktoForms2 :: Client Calc

Ignoring the confusing field names (I do this so I don't have to clutter my prod instance with unused fields) the approach is that you have the rate stored in a hidden field (like you said) and then you prompt the user for the lot size.  Only when they submit the lot size, you actually multiply the lot size by the hidden rate before submitting the form to the Marketo db.

You'd probably find it more visually appealing to have a second hidden field that stores the lot size * rate.  Then you don't have to "magically" update the lot size field while the user is watching.  Or you could just hide the form while you're submitting, same difference so they don't see that.  Anyway, this is just as a quick-and-dirty demo of how you can massage field values any way you want before posting to Marketo.

1 reply

Edward_Unthank_
Level 7
July 22, 2015

If you're doing real-time calculations with the point of showing a prospect, I'd do that with JavaScript, and then send the calculated value to Marketo as a field value. Those kinds of calculations will be very easy to do with some simple JavaScript coding.

Marketo can do linear math (adding and subtracting) but anything more complex than that is easier to do outside of Marketo.

Cheers,

Edward Unthank | Founder, Etumos

Level 2
July 23, 2015

This sounds interesting.  Any example you can provide as to how to pass that data value to Marketo.  What JS method would one use?

Thanks so much!

When life lends you lemons, make applesauce.
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
July 24, 2015

JS has all the built-in math functions you need.

Here's a naive implementation of what you're talking about: MktoForms2 :: Client Calc

Ignoring the confusing field names (I do this so I don't have to clutter my prod instance with unused fields) the approach is that you have the rate stored in a hidden field (like you said) and then you prompt the user for the lot size.  Only when they submit the lot size, you actually multiply the lot size by the hidden rate before submitting the form to the Marketo db.

You'd probably find it more visually appealing to have a second hidden field that stores the lot size * rate.  Then you don't have to "magically" update the lot size field while the user is watching.  Or you could just hide the form while you're submitting, same difference so they don't see that.  Anyway, this is just as a quick-and-dirty demo of how you can massage field values any way you want before posting to Marketo.