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

Uncheck a checkbox and tturn field to zeo

Community Beginner ,
Jul 30, 2021 Jul 30, 2021

Copy link to clipboard

Copied

I have run this script for a dollar value field

{if (this.getField("ChkFee").value = "Off") {
event.value = 0}}

I am trying to get a checkbox to return a value of 0 to a calculated field (using javascript) when the checkbox is unchecked (off).  I want to fill in that field with 0 if there is no check there.  This does not seem to do that.  Does anyone know the problem with the code?

TOPICS
JavaScript , PDF forms

Views

383

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 ,
Jul 30, 2021 Jul 30, 2021

Copy link to clipboard

Copied

When comparing use double ==,    "ChkFee").value == "Off"

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 ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

Thank you for your response.  I still cannot get it to insert a zero into that field after i made the correction to two ='s.  Checking the box seems to have no effect.  I have this in the custom calculation field.

 

{if (this.getField("ChkFee").value == "Off") {
event.value = 0}}

 

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 ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

Make sure checkbox name is same as in script.

Do you have any other calculations that could affect that field?

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 ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

The checkbox name is in the script.  No other calculations.  I also tried this as well:

{if (this.getField("ChkFee").value == "Off") {
this.getField("amtComp").value = 0}}

that does not work either.  Does calculation order have anything to do with this.  I just don't know enough to write the proper code.

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 ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

LATEST

I see now!  I misnamed the field!  It works. Thank you!!

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