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

How To Set Two Text Fields To Be Equal When A Checkbox is Checked

New Here ,
Oct 20, 2021 Oct 20, 2021

Hello everyone,

 

I am new to this platform and I would greatly appreciate your help.

I am working on creating a form where I am trying to set some text fields to be equal only if a checkbox is checked to prevent duplication of effort from the customer's point of view. Below is a snip from the form to better explain the situation.

defaultqwpknud3n5gx_0-1634771782706.pngexpand image

When Checkbox "33" is checked, text field "8" is set to equal "20", and "9" equal "21" and so forth. I used the below code (This is a portion of the code to avoid redundancy) to accomplish the required, but I get no output from the software:

if (getField("33").value=="Yes")
getField("8").value = getField("20").value
else getField("20").value = "";

if (getField("33").value=="Yes")
getField("9").value = getField("21").value
else getField("21").value = "";

 

It's worth noting I have checkboxes numbers "1","32" & "34" programmed such that, the text fields below each checkbox are hidden if the boxes are unchecked, and once the boxes are checked they are visible for editing. 

 

Adobe Softaware used: Adobe Acrobat Pro DC (32-bit).

Any help would be greatly appreciated.

1.1K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Oct 21, 2021 Oct 21, 2021

Do you want to field "8" to be equal to field "20" or other way around?

Use this as 'Mouse UP' event of checkbox(replace field names if you need other way around):

this.getField("8").value = event.target.value != "Off" ? this.getField("20").value : "";
this.getField("9").value = event.target.value != "Off" ? this.getField("21").value : "";

View solution in original post

Translate
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 20, 2021 Oct 20, 2021

I've moved this from the Using the Community forum (which is the forum for issues using the forums) to the Acrobat forum so that proper help can be offered.

Translate
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 21, 2021 Oct 21, 2021

Do you want to field "8" to be equal to field "20" or other way around?

Use this as 'Mouse UP' event of checkbox(replace field names if you need other way around):

this.getField("8").value = event.target.value != "Off" ? this.getField("20").value : "";
this.getField("9").value = event.target.value != "Off" ? this.getField("21").value : "";

Translate
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 ,
Oct 21, 2021 Oct 21, 2021

Hello Nesa,

Thanks for your attempt to help me figure this out. I tried the code as shown, but the system didn't output anything. I attached the document to communicate better, find attached. 

Translate
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 21, 2021 Oct 21, 2021

I writed in my previous post to change field names if you need other way around, so use code like this:

this.getField("20").value = event.target.value != "Off" ? this.getField("8").value : "";

Translate
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 ,
Oct 21, 2021 Oct 21, 2021

Hello Nesa,

There has been an oversight on my part. The code works well, thanks for the help. I have an additional question if you dont mind. I programmed in a clear button in this form to reset the content for the whole form, additionally check boxes 1,34 & 32 are programmed to hide their respective text fields when the checkboxes arent ticked.

When I press clear form after populating the text field, the state of the checkbox become unchecked, but the text fields are visible instaed of hidden. 

Thanks for your thoughts in advance. 

Translate
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 ,
Oct 21, 2021 Oct 21, 2021
LATEST

@Nesa Nurani I figured it out, thanks for your help. 

Translate
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