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

event value = yes

Community Beginner ,
Feb 15, 2023 Feb 15, 2023

Copy link to clipboard

Copied

Hello, I created a javascript to create a value of "yes" or "no" but the words are not populating.  I am trying to write a scipt that if this text box "Supervision Minimum Face to Face Met 2" is >= 2 then Yes should populate otherwise No should populate.  Here is my script

 

var nSubTotal = this.getField("Supervision Minimum Face to Face Met 2").value;
if( nSubTotal >= 2) event.value = yes;
else event.value = no; 

 

Thank you.

TOPICS
JavaScript

Views

1.5K

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

correct answers 1 Correct answer

Community Expert , Feb 15, 2023 Feb 15, 2023

It should be written like this, though:

 

event.value = (this.getField("Supervision Minimum Face to Face Met 2").value >= 2) ? "Yes" : "No";

Votes

Translate

Translate
Community Expert ,
Feb 15, 2023 Feb 15, 2023

Copy link to clipboard

Copied

Hi, 

 

The values of yes and no are strings of texts.

 

They must be enclosed with quotes (i.e. "yes" ,  "no").

 

You may also simplify the script with a single line of code ( shown in the example below as a JavaScript ternary expression):

 


(this.getField("Supervision Minimum Face to Face Met 2").value >= 2) ? event.value = "Yes" :
event.value = "No"; 

 

 

 

 

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 ,
Feb 15, 2023 Feb 15, 2023

Copy link to clipboard

Copied

It should be written like this, though:

 

event.value = (this.getField("Supervision Minimum Face to Face Met 2").value >= 2) ? "Yes" : "No";

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 ,
Feb 15, 2023 Feb 15, 2023

Copy link to clipboard

Copied

My mistake.

 

Thank you for always keeping an eye!

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 ,
Feb 15, 2023 Feb 15, 2023

Copy link to clipboard

Copied

Thank you both! This worked.  

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 ,
Feb 15, 2023 Feb 15, 2023

Copy link to clipboard

Copied

LATEST

You're welcome.

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