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

Change text color instantly when other field values are changed

Community Beginner ,
Mar 10, 2023 Mar 10, 2023

Hello,

I'm sure this won't take up much time but I'm a little lost.

See attached lot coverage form. It enables designers to figure out if their design exceeds the maximum lot coverage percentage for certain municipalities. If the percentage is under the max, the text is green. If not, the text turns red. My concern is when/if the user decides to switch the "Municipality" value. The color does not update until I re-enter the square footage.

 

For Example, if the user selects "Cooper City" for their municipality and their percentage is 59%, the numbers will turn red because it is over the max which is 55%. Great. Now, if the user suddenly switches their "Municipality" value to Lighthouse Point, the numbers should turn green automatically since it is under the max which is 75%. However, this is not the case. Is there something that I am doing wrong with my script?

TOPICS
Create PDFs , How to , JavaScript , PDF forms
1.3K
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
1 ACCEPTED SOLUTION
Community Expert ,
Mar 10, 2023 Mar 10, 2023
LATEST

I'm not sure, but you have issues with your code. You have to add to it a condition that checks if the divisors are zero (or empty), and if so not perform the calculation, because division by zero is not allowed and produces odd results.

View solution in original post

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 ,
Mar 10, 2023 Mar 10, 2023

Under the Properties of the Municipality field, in the Options tab, tick the box that says "Commit selected value immediately". Also, there's no point in locking the fields. You're only stopping yourself from editing them more easily and quickly...

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 Beginner ,
Mar 10, 2023 Mar 10, 2023

Thanks for the reply try67. After ticking the box, there seems to be another issue. The numbers are changing colors, but not accurately. Some of the values are forcing the numbers to change color even if the number exceeds the max.What could be the issue?

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 ,
Mar 10, 2023 Mar 10, 2023
LATEST

I'm not sure, but you have issues with your code. You have to add to it a condition that checks if the divisors are zero (or empty), and if so not perform the calculation, because division by zero is not allowed and produces odd results.

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