• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Need To Place A Check Mark In A Box Based On Calculated Fields

Community Beginner ,
Oct 28, 2021 Oct 28, 2021

Copy link to clipboard

Copied

This is my first post and I'm just starting out so please excuse my lack of knowledge. I can't figure out how to place a check mark in one of two fields automatically based on a calculated value compared to a range value. Any help is highly appreciated!form.jpg

TOPICS
Acrobat SDK and JavaScript

Views

275

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
community guidelines
Community Beginner ,
Oct 29, 2021 Oct 29, 2021

Copy link to clipboard

Copied

I 'm still trying to make this work and feel I'm close but still not there.

I can blank out the PASS field if a check mark is in the FAIL field but if I try to then add the script to blank out the FAIL field, it all stops working.

 

//PASS FIELD//

var VarianceRow1_2 = Number(this.getField("VarianceRow1_2").value);

if (VarianceRow1_2>-1.0 && VarianceRow1_2<1.0) event.value = resetForm(["FAILRow1_2"]);

if (VarianceRow1_2>=-1.0 && VarianceRow1_2<=1.0) event.value = "✔";

//FAIL FIELD//

var VarianceRow1_2 = Number(this.getField("VarianceRow1_2").value);

if (VarianceRow1_2<-1.0 || VarianceRow1_2>1.0) event.value = resetForm(["PASSRow1_2"]);

if (VarianceRow1_2<-1.0 || VarianceRow1_2>1.0) event.value = "✔";

Votes

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
community guidelines
Community Beginner ,
Oct 29, 2021 Oct 29, 2021

Copy link to clipboard

Copied

I finally stumbled my way to the correct script. Whew! Learning by trial and error can be rough.

 

//PASS FIELD//

var VarianceRow1_2 = Number(this.getField("VarianceRow1_2").value);

if (VarianceRow1_2>=-1.0 && VarianceRow1_2<=1.0) event.value = "✔";

else event.value = resetForm(["PASSRow1_2"])


//FAIL FIELD//

var VarianceRow1_2 = Number(this.getField("VarianceRow1_2").value);

if (VarianceRow1_2<-1.0 || VarianceRow1_2>1.0) event.value = "✔";

else event.value = resetForm(["FAILRow1_2"])

Votes

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
community guidelines
Community Expert ,
Oct 29, 2021 Oct 29, 2021

Copy link to clipboard

Copied

It's not quite correct... This part is wrong:

VarianceRow1_2<-1.0

It should be:

VarianceRow1_2<=1.0

 

Also, I would advise against using the check-mark character in your code directly.

You can replace it with this:

String.fromCharCode(10004)

Votes

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
community guidelines
Community Expert ,
Oct 29, 2021 Oct 29, 2021

Copy link to clipboard

Copied

This is also wrong:

event.value = resetForm(["PASSRow1_2"])

If you want to clear the field use this, instead:

event.value = "";

Votes

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
community guidelines
Community Beginner ,
Nov 01, 2021 Nov 01, 2021

Copy link to clipboard

Copied

Thank you TRY67. Especially for the String.fromCharCode(10004). Using a check mark was causing problems. I had no clue how to fix it. I guess since I'm completely new to Java scripts, I'll find a reference list of commands that can be used. Any suggestions?

Thanks again for your help!

Steve

Votes

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
community guidelines
Community Expert ,
Nov 01, 2021 Nov 01, 2021

Copy link to clipboard

Copied

LATEST

That list is enormous. If you need help with something specific let us know and we'll help you out...

Votes

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
community guidelines