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
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.
Copy link to clipboard
Copied
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"...