Support » Plugin: Calculated Fields Form » Different values for zip code

• Resolved LettuceCheese

(@lettucecheese)

Hi. I’m trying to make a form where I charge different rates depending upon a person’s zip code. I thought it would be easy. I tried the following two examples (fieldname3 is where they input the zip code). I’ve tried a couple other things that also didn’t work.

Thanks.

Example 1:
if(fieldname3 = 95124, 70, 0)
if(fieldname3 = 95125, 70, 0)
if(fieldname3 = 94085, 100, 0)
if(fieldname3 = 94086, 100, 0)
if(fieldname3 = 95116, 120, 0)

Example 2:
if(fieldname3 = 95124) v = 70;
if(fieldname3 = 95125) v = 70;
if(fieldname3 = 94085) v = 100;
if(fieldname3 = 94086) v = 100

https://wordpress.org/plugins/calculated-fields-form/

Viewing 1 replies (of 1 total)
• Plugin Author codepeople

(@codepeople)

Hi,

First, in javascript the operator for equality is “==”, because the operator “=” represent the assignation.

Second, if you want use the operation IF(condition, value, value ), the equation would be:

IF(fieldname3 == 95124, 70, IF(fieldname3 == 95125, 70, IF(fieldname3 == 94085, 100, IF(fieldname3 == 94086, 100, IF(fieldname3 == 95116, 120, 0)))))

Third, if you prefer to use the equation with multiple lines, you need return a value from the equation, and define the equation with the following format:

(function(){
if(fieldname3 == 95124) return 70;
if(fieldname3 == 95125) return 70;
if(fieldname3 == 94085) return 100;
if(fieldname3 == 94086) return 100;
})()

Best regards.

Viewing 1 replies (of 1 total)
• The topic ‘Different values for zip code’ is closed to new replies.