Skip to main content
Participant
March 24, 2023
Question

Syntax Error 1: at line 2 - please help

  • March 24, 2023
  • 2 replies
  • 1540 views

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";
}

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
March 24, 2023

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.

Inspiring
March 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";
}

Participant
March 24, 2023

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

Inspiring
March 24, 2023

Have you defined DH3 somewhere else?