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

Adding text to a text box when multiple checkboxes are marked

Community Beginner ,
Feb 07, 2024 Feb 07, 2024

Copy link to clipboard

Copied

I am working on adding text to a text box when multiple checkboxes are marked/selected. I have looked all through the links that have been sent to me and tried several suggested options, but nothing is working for me. (this is why I do not make my living as a code specialist!) 

 

I need for these boxes outlined in Red :

 

Anne35206694eyto_0-1707330580766.png

to add text to this box below all at the same time if the box is checked.. 

 

Anne35206694eyto_2-1707330580784.png

 

I will be doing this same thing from drop down boxes once I have this part with the checkmarks completed.

Thanks in advance for any assistance for this newbie! 

TOPICS
Windows

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 Expert ,
Feb 07, 2024 Feb 07, 2024

Copy link to clipboard

Copied

You can use something like this as custom calculation script of text field where you want to show text:

var c1 = this.getField("Check Box1").valueAsString;
var c2 = this.getField("Check Box2").valueAsString;
var c3 = this.getField("Check Box3").valueAsString;
//Use your actual names for the checkboxes

if(c1 !== "Off" && c2 !== "Off" && c3 !== "Off")
 event.value = "Some text";
else
 event.value = "";//set event.value to desired value when chekboxes are not checked

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 08, 2024 Feb 08, 2024

Copy link to clipboard

Copied

Thank-you so much! 

In this line.......... 

set event.value to desired value when chekboxes are not checked

Is this where I type the text that I want to  be placed in this text box? The text for each checkbox is different; do I add all 3 options in this spot? 

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 08, 2024 Feb 08, 2024

Copy link to clipboard

Copied

event.value = "" means if no conditions are met field will be empty, instead of set field to be empty you can set it to some other default text if you need, if not than leave as it is.

Where it says "Some text" that is where you input your text to show in the field.

If you have multiple text, use 'else if' conditions for each text.

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 08, 2024 Feb 08, 2024

Copy link to clipboard

Copied

Thank-you very much Nesa! 

I have applied the code that you provided and I think I am missing something since I cannot close the java script box and I hear a dinging sound with a highlight that something is wrong. No matter what I "fix", I can't get past it. 

I think I am going in the right direction, but this is what I have, can you help me tweek it appropriately??  I am working with 3 different checkboxes at the moment, each should populate its own text. 🙂 

 

var c1 = this.getField("Completed Operations").valueAsString;
var c2 = this.getField("Primary Non-Contributory").valueAsString;
var c3 = this.getField("30 Day Cancellation").valueAsString;
//Use your actual names for the checkboxes

if(c1 !== "Off" && c2 !== "Off" && c3 !== "Off")
event.value = "Certificate holder is an Additional Insured and will provide Ongoing & Completed Operations Coverage in accordance with policy language, when under contract with insured, relating to general liability.";
else if = "Coverage extended to the scheduled Additional Insured, as afforded in the Comprehensive General Liability coverage, is provided on a primary, noncontributory, or excess basis only as defined in the policy language."
else if = "We will endeavor to mail written notice of cancellation at least ten (10) days before the date of cancellation if we cancel for non-payment of premium, thirty (30) days before the cancellation date if we cancel for any other reason, as provided in policy language."
else
event.value = "";//set event.value to desired value when chekboxes are not checked

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 08, 2024 Feb 08, 2024

Copy link to clipboard

Copied

LATEST

You are missing condition for both 'else if'.

var c1 = this.getField("Completed Operations").valueAsString;
var c2 = this.getField("Primary Non-Contributory").valueAsString;
var c3 = this.getField("30 Day Cancellation").valueAsString;


if(c1 !== "Off" && c2 !== "Off" && c3 !== "Off")//this is 1st condition: all 3 checkboxes needs to be checked
event.value = "Certificate holder is an Additional Insured and will provide Ongoing & Completed Operations Coverage in accordance with policy language, when under contract with insured, relating to general liability.";

else if(Replace this text with 2nd condition)
event.value = "Coverage extended to the scheduled Additional Insured, as afforded in the Comprehensive General Liability coverage, is provided on a primary, noncontributory, or excess basis only as defined in the policy language.";
else if(Replace this text with 3rd condition)
event.value = "We will endeavor to mail written notice of cancellation at least ten (10) days before the date of cancellation if we cancel for non-payment of premium, thirty (30) days before the cancellation date if we cancel for any other reason, as provided in policy language.";

else
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