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

Need Help: I need a check box to auto fill a set value in separate text field.

Guest
Dec 27, 2011 Dec 27, 2011

Hi, this is my first time with inserting scripts into a PDF Form.

We have a form that requires the user to check a box regarding medical conditions they have (i.e. Asthma, Diabetes, Hypertension).  Later in the form, they have to type out the same condition into a text box. (I know stupid to double document, but it is required).  Is there a script that will auto fill the text box when they check the box?  For example, if they check asthma, the text box on a later page in the PDF will say "Asthma, controlled."  Is this possible?

In addition, if they don't click Asthma, and do click Diabetes, could it add Diabetes to the first text box, but if they check both, it would add Asthma to box 1 and Diabetes to box 2?

Any help would be GREATLY appreciated.

I'm using Acrobat 9

Thanks!

TOPICS
PDF forms
28.9K
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
New Here ,
Dec 30, 2011 Dec 30, 2011

You might try entering this scipt in the textbox that is to contain the word "Asthma" where appropriate.

The script is based on checkboxes with names "cbAsthma" and "cbDiabetes"

The script as it stands adds all the text in one box.

As always with these scripts they are case sensitive.

var a =""

if (this.getField("cbAsthma").value == "Yes")
{
a="Asthma (controlled) "
}

if (this.getField("cbDiabetes").value =="Yes")
{
a=a + "Diabetes"
}

event.value=a

Hope this is somewhere near what you are looking for

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 Beginner ,
Sep 19, 2015 Sep 19, 2015

Will try thank you, but submit check box is not part of the check boxes to populate the text box, is there anyway to exclude it.

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
LEGEND ,
Sep 19, 2015 Sep 19, 2015

It is not used in the script, so it's already excluded.

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 Beginner ,
Sep 19, 2015 Sep 19, 2015

George

Tried, and put 4 CheckBox, and added the "CheckBox3" but still get the error

getField("CheckBox " + i) is null

17:AcroForm:DisabilityCode:Calculate'

in javascript consol

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 ,
Mar 17, 2022 Mar 17, 2022
LATEST

hi! is there anyway to see that sample as well. Im trying to do the same exact thing.  Check a box and the text field produces a number.  Any help would be greatly appreciated!

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
Guest
Jan 05, 2012 Jan 05, 2012

Thanks for script. Very help full answer. Stay tuned.

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
Guest
Feb 15, 2012 Feb 15, 2012

One more question:

So I've got the checkboxes populating, but I need multiple text boxes to populate into one text box.  I've got it to work with....

{

a=a + "\n " + (this.getField("Other Current Illnesses 6").value)

}

However, if the field is blank, it gives me a blank line.   What is the code if the box is empty to "skip" that text box?

Here is what I tried, but it takes everything away even if there is something in the textbox:

if (this.getField("Other Current Illnesses 6").value !==null) {a=a + ""} else

{

a=a + "\n " + (this.getField("Other Current Illnesses 6").value)

}

Any 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
Guest
Feb 15, 2012 Feb 15, 2012

I figured it out.  The line should read:

if (this.getField("Other Current Illnesses 1").value =="") {a=a + ""} else

{

a=a + "\n " + (this.getField("Other Current Illnesses 6").value)

}

just in-case anyone wanted to know.

Thanks

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 ,
Apr 12, 2013 Apr 12, 2013

This solution is very nice, however I have a question.  Is it possible to add some code to allow the user to still type their own text in the text field along with the populated text from the text boxes? Right now, it lets you type but once you click off, the added copy goes away.

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
Guest
Nov 25, 2013 Nov 25, 2013

how can I get this code to work in Adobe LiveCycle Designer?

var a =""

if (this.getField("cbAsthma").value == "Yes")
{
a="Asthma (controlled) "
}

if (this.getField("cbDiabetes").value =="Yes")
{
a=a + "Diabetes"
}

event.value=a

It works great in Adobe Acrobat, but when I take my form into Adobe ES it no longer works.

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
LEGEND ,
Nov 25, 2013 Nov 25, 2013

You need to look at the scripting documentation included with LiveCycle Designer and change the JavaScript to comply with the JavaScript syntax for LiveCycle Designer.

Are you getting any errors?

In preview are you getting any errors in the JavaScript console?

The "if{...} else {...}" has a different syntax in LiveCycle.

There are forums here for LiveCycle.

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 ,
Dec 30, 2011 Dec 30, 2011

The script should be on the calculate tab under custom calculation script

The checkboxes should be named without the quote marks

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 ,
Dec 14, 2020 Dec 14, 2020

Thank you so much!!!!!

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