Highlighted

PDF Form - Script to Auto Check a CheckBox when the Value in a Text Field is Greater than $0.

New Here ,
May 28, 2020

Copy link to clipboard

Copied

Dear All,

I like to seek your help for a script to auto check a checkbox when a a text field is greater than $0.

My script as below but doesn't work.

 

var TextField = number(this.getField("=TextField").value);
if (TextField = 0) {

this.getField("CheckBox").checkThisBox(0, true);
} else {
this.getField("CheckBox").checkThisBox(0, false);
}

 

But it doesn't work. Appreciate the guidance here.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

What are the actual names of your fields?

You have multiple errors in your code...

- It's Number(), not number().

- It's ==0, not =0. Also, if you want to check if the value is greated then zero then you should use >0.

And where did you place this code?

Topics

Create PDFs, How to, PDF forms

Views

225

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

PDF Form - Script to Auto Check a CheckBox when the Value in a Text Field is Greater than $0.

New Here ,
May 28, 2020

Copy link to clipboard

Copied

Dear All,

I like to seek your help for a script to auto check a checkbox when a a text field is greater than $0.

My script as below but doesn't work.

 

var TextField = number(this.getField("=TextField").value);
if (TextField = 0) {

this.getField("CheckBox").checkThisBox(0, true);
} else {
this.getField("CheckBox").checkThisBox(0, false);
}

 

But it doesn't work. Appreciate the guidance here.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

What are the actual names of your fields?

You have multiple errors in your code...

- It's Number(), not number().

- It's ==0, not =0. Also, if you want to check if the value is greated then zero then you should use >0.

And where did you place this code?

Topics

Create PDFs, How to, PDF forms

Views

226

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
May 28, 2020 0
Participant ,
May 28, 2020

Copy link to clipboard

Copied

A couple issues with your code.

1. don't wrap 'this.getField(=TextField").value in  number() and

2. you have an '=' sign in this.getField(=TextField").value. Remove it.

3. Your code should be checking for a value of the TextField > 0, not = 0.

4. Make sure the text field is formatted to number so that only numbers can be entered if it is your intent to only have numbers entered.

Your code should be:

var TextField = this.getField("TextField").value;

if (TextField > 0) {
this.getField("CheckBox").checkThisBox(0, true);
} else {
this.getField("CheckBox").checkThisBox(0, false);
}

 

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
Reply
Loading...
May 28, 2020 0
Most Valuable Participant ,
May 28, 2020

Copy link to clipboard

Copied

What are the actual names of your fields?

You have multiple errors in your code...

- It's Number(), not number().

- It's ==0, not =0. Also, if you want to check if the value is greated then zero then you should use >0.

And where did you place this code?

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
Reply
Loading...
May 28, 2020 1
New Here ,
May 28, 2020

Copy link to clipboard

Copied

Hi try67,

 

My sincere apologies. I lost touch with javascript and forgotten about double equality. The small "n" was a typo.

 

My text field is "Text4". And checkbox is "CheckBox27".  I rewrite as below and has pasted it under custom calculation script in text field "Text4" and it is working! Thank you so  much for the guidance.

 

var Text4 = Number(this.getField("Text4").value);
if (Text4 == 0) {

this.getField("CheckBox27").checkThisBox(0, false);
} else {
this.getField("CheckBox27").checkThisBox(0, true);
}

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
Reply
Loading...
May 28, 2020 0