Skip to main content
Mar 18, 2019 7:16 PM UTC
Question

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

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 is closed to new replies. Start a new post to keep the conversation going.

3 replies

try67
Community Expert
Community Expert
Mar 18, 2019 9:15 PM UTC

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

Translate
Mar 19, 2019 1:22 PM UTC

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.]

Translate
try67
Community Expert
Community Expert
Mar 19, 2019 1:36 PM UTC

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...)

Translate