Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Help with JavaScript code for IF with a price range

New Here ,
Oct 14, 2025 Oct 14, 2025

Looking to have a form that can populate when I enter one rate. I need a javascript that seems relativley easy. 

When I enter a rate in "Box A" I would like "Box B" to formulate, however I would like a price range to be added. 

Example:

"Box A"- (Price for snow removal) Rate can be anywhere from $40-50 to calculate "Box B" (salting rate) which would be $30 for the range of $40-50.00 

 

Any help is appreciated!!!  

48
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 22, 2025 Oct 22, 2025
LATEST

Are there any ohter price ranges that you would apply different "salting rates" to? What if the Box A is set to 0? What if it's set to $10? What if it's set to $60? 

 

You might be able to make the necessary modifications yourself - try this as the custom calculation script for Box B:

 

// get the current value from "BoxA"

var boxA = this.getField("BoxA").value;
var thisValue = 0;
if (boxA == "" || boxA == 0) {
    thisValue = 0;
}
else if (boxA > 0 && boxA < 40) {
    thisValue = 5;
}
else if (boxA >= 40 && boxA <= 50) {
    thisValue = 30;
}
else {
    thisValue = 50;
}
event.value = thisValue;
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines