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.
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?
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);
}
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?
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);
}

