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

Problem with simple "if" statement

New Here ,
Jul 18, 2021 Jul 18, 2021

Copy link to clipboard

Copied

Hello all,

I'm having trouble with what I think is a simple "If" statement. I'm trying to reset two checkboxes if one checkbox is checked. Here is my code:

<code>

If (this.getField("NoUrinaryProblems").value == "yes") {
this.getField("UninaryProblems").value = "Off";
this.getField("UrinaryPain").value = "Off";
}

</code>

I'm getting an error on line 2 saying missing ; before statement. I'm not a Java expert but I can't seem to see what's wrong, especially because I basically copied the statements from the forum and just changed the names. This is what I have tried:

* If I remove the "if" statement it works, checking the target box (NoUrinaryProblems) unchecks the two other fields no matter what the status of the first checkbox is

* Moved the { to the next line, then I don't get the error but it doesn't work at all

* Experimented with changing the double quotes to single quotes, no effect.

* put a ; after the value == "yes" part

Can anyone tell me what I'm doing wrong here?

Thanks,

stevinga

TOPICS
Acrobat SDK and JavaScript , Windows

Views

40

Likes

Translate

Translate

Report

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
New Here ,
Jul 18, 2021 Jul 18, 2021

Copy link to clipboard

Copied

Actually all, sorry I figured out my problem. It ended up being the capital "I" in "If" -- changed it to lower case and it worked... kind of. I also had to change the value == thing to ().ischecked(0) becase that worked better than the value thingy... actually the value thingy didn't work at all.

Likes

Translate

Translate

Report

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 ,
Jul 19, 2021 Jul 19, 2021

Copy link to clipboard

Copied

LATEST

It's important to keep in mind that JS is case-sensitive. So if the value of the field is actually "Yes" and you compare it to "yes", it will return false. And if you use "If" instead of "if" that will return an error.

Also, there's no such thing as an "ischecked" method. There is "isBoxChecked"...

Likes

Translate

Translate

Report

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