Skip to main content
chrisg90226064
Participating Frequently
May 21, 2019
Question

Help with JavaScript Formula off a dropdown menu

  • May 21, 2019
  • 1 reply
  • 996 views

Hi I need help with a formula based on a dropdown menu entry:

If "No.ofMeals" selected is 5 I need the "GramsCarbohydrates" to divide by 2 and show in the last two boxes - meal 5 and meal 4 boxes.

If "No.ofMeals" selected is 4 I need the "GramsCarbohydrates" to divide by 2 and show in the boxes meals 4 and meals 3 and not to show at all in Meal 5 box.

If "No.ofMeals" selected is 3 I need the "GramsCarbohydrates" to divide by 2 and show in the boxes Meals 3 and Meals 2 and not to show in Meals 5 or 4 Boxes.

Hope that makes sense.

Thanks,

Chris


This topic has been closed for replies.

1 reply

Inspiring
May 21, 2019

If I were doing this I'd use a custom Validate script for the dropdown. But I'd need to know what the possible selections are. You've mentioned dropdown selections of 5, 4, and 3, but are there any others? In particular, it there one that indicates no valid selection (e.g., "--" or " ")?

chrisg90226064
Participating Frequently
May 21, 2019

Hi George,

the dropdown menu is number of meals - and the values are 3 meals, 4 meals or 5 meals only so the form suggests 3 meals as a minimum. So there aren't any others.

literally just three option in the drop down 3,4, or 5. Theres no options for no selection.

Inspiring
May 21, 2019

OK, with that and further review of the form, it would probably be best to use custom validation script for the Grams fields. But before I suggest a script, are you calculating the Grams given the Calories, or vice versa, or are they both manually entered, or something else?