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

Change output textfield based on input checkboxes

New Here ,
Jul 25, 2024 Jul 25, 2024

Copy link to clipboard

Copied

Good afternoon,

I have a text field which should standard show the text “Permanent Architecture” if none of the checkboxes are checked. There are 4 checkboxes, 10 Y, 12 Y, 15 Y and 20 Y. These checkboxes are set up in a way that the user only can check one checkbox at a time. So based on which checkbox is checked (or if none is checked), the text in my text field should change like the following:

 

10 Y – If this checkbox is checked the text should change to “Permanent Architecture 10 Years”

12 Y - If this checkbox is checked the text should change to “Permanent Architecture 12 Years”

15 Y - If this checkbox is checked the text should change to “Permanent Architecture 15 Years”

20 Y - If this checkbox is checked the text should change to “Permanent Architecture 20 Years”

 

I assume this probably should be coded in Javascript. But since I don’t have any experience with Javascript, I hope that someone is willing to help me with this?

Thank you in advance.

TOPICS
How to , JavaScript , PDF

Views

321

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 25, 2024 Jul 25, 2024

Copy link to clipboard

Copied

Enter the following as a custom calculation script in the text field:

event.value="Permanent Architecture";
if(this.getField("10 Y").value!="Off")
{event.value="Permanent Architecture 10 Years"}
if(this.getField("12 Y").value!="Off")
{event.value="Permanent Architecture 12 Years"}
if(this.getField("15 Y").value!="Off")
{event.value="Permanent Architecture 15 Years"}
if(this.getField("20 Y").value!="Off")
{event.value="Permanent Architecture 20 Years"}

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
New Here ,
Jul 25, 2024 Jul 25, 2024

Copy link to clipboard

Copied

Thank you for your help. I have entered this code but it seems not to be working exaclty as it should. Because no matter which check box I check, the textfield always shows the same result: "Permanent Architecture 10 Years". It seems as if the other If-statement are not taken into account.

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 25, 2024 Jul 25, 2024

Copy link to clipboard

Copied

Are 10 Y, 15 Y, etc. the names of the checkboxes or the export values?

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
New Here ,
Jul 25, 2024 Jul 25, 2024

Copy link to clipboard

Copied

No, errors in the console at all. But I found what is generating the issue. I named all the checkboxes the same so that only one checkbox at a time can be checked. If I give them different names, it works as it should but then the user can check more than 1 checkbox at a time. Any idea how I can work around this?

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 25, 2024 Jul 25, 2024

Copy link to clipboard

Copied

They way you posed your original question, it looked as if 10 Y, 15 Y, etc. were field names.  Assume your checkboxes are all named "Years", with 10 Y, etc as the export values.  Here's the script:

 

 

var yrs=this.getField("Years").value;
if(yrs=="Off")
{event.value="Permanent Architecture"}
if(yrs=="10 Y")
{event.value="Permanent Architecture 10 Years"}
if(yrs=="12 Y")
{event.value="Permanent Architecture 12 Years"}
if(yrs=="15 Y")
{event.value="Permanent Architecture 15 Years"}
if(yrs=="20 Y")
{event.value="Permanent Architecture 20 Years"}

 

 

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
New Here ,
Jul 26, 2024 Jul 26, 2024

Copy link to clipboard

Copied

LATEST

This works perfectly!  Thank you so much for your help.

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