Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
It is not used in the script, so it's already excluded.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
Thanks for script. Very help full answer. Stay tuned.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
The script should be on the calculate tab under custom calculation script
The checkboxes should be named without the quote marks
Copy link to clipboard
Copied
Thank you so much!!!!!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now