Skip to main content
March 18, 2019
Question

Trying to check a Checkbox if the data in Form Field 1 equals a certain value

  • March 18, 2019
  • 1 reply
  • 384 views

New to writing JavaScript.

ContractRateBook will have a 3-digit number coming form my database.

Read somewhere that I need to use event.value but not sure how.

Came up with this but not working.

Theft is the name of my Checkbox

var x = this.getfield("ContractRateBook").value;

if (x == 103)

{event.value = 0;

getField("Theft").checkThisBox(0,true);}

Thanks.

Pat

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
March 18, 2019

When you say the value is coming from your database, do you mean you import it directly into the field? If so, how?

March 19, 2019

Yes.

Once I save the document with proper Form Field Names, I upload it to my Contract Tracking software where the Field Names automatically pull data from the software’s database.

I then run the document from within the software and it prints with the data in the fields.

Thanks.

var x = this.getfield("ContractRateBook").value;

if (x == 103)

{

event.value = 15;

getField("Theft").checkThisBox(0,true);

}

else

{

event.value = 0;

getField("Theft").checkThisBox(0,false);

}

[Private info removed. -Mod.]

try67
Community Expert
Community Expert
March 19, 2019

OK, then you can use this code as a doc-level script:

var x = Number(this.getField("ContractRateBook").value);

if (x == 103) this.getField("Theft").checkThisBox(0,true);

(Note that when you reply by email it includes your personal details in the signature. You might want to avoid that...)