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

Syntax Error 1: at line 2 - please help

Community Beginner ,
Mar 24, 2023 Mar 24, 2023

I am greating a form with a score rating for work. ex. If the dollar amount is lower then $5000 then its rated a 1, if its between $5000 & $25000 its a 2, if its above $25000 its a 3. I am currently getting an error stating "SyntaxError: syntax error 1: at line 2." Can someone please help me and let me know what is wrong with my code?

 

if (DH3 >= 1.00) && (DH3 < 5000.00)) {
event.value = "1";
}
else if (DH3 >= 5000.00) && (DH3 < 25000.00)) {
event.value = "2";
}
else if (DH3 >= 25000.00) && (DH3 < 100000.00)) {
event.value = "3";
}

TOPICS
Create PDFs , General troubleshooting , JavaScript , PDF forms
1.5K
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
Explorer ,
Mar 24, 2023 Mar 24, 2023

You are missing a parenthesis in your if statements:

if ((DH3 >= 1.00) && (DH3 < 5000.00)) {
event.value = "1";
}
else if ((DH3 >= 5000.00) && (DH3 < 25000.00)) {
event.value = "2";
}
else if ((DH3 >= 25000.00) && (DH3 < 100000.00)) {
event.value = "3";
}

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

Thank you! The error went away but its not calculating for me. Is there something I am doing wrong?

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
Explorer ,
Mar 24, 2023 Mar 24, 2023

Have you defined DH3 somewhere else?

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

No I have not.

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
Explorer ,
Mar 24, 2023 Mar 24, 2023

What is DH3 supposed to be? A value from another field? You would need to define what DH3 is in your script.

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

In addition to all the correct remarks given above, you really need to add a default else command at the end of the code, in case the value is smaller than 1, larger than 100,000, or empty.

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