Highlighted

Need help with a java script in Adobe Acrobat DC for auto fill text when a check box is selected

New Here ,
Sep 17, 2020

Copy link to clipboard

Copied

Hello-

I am learning how to use prepare forms and I am working on a patient proceedure form for a doctor. I am having trouble with java script (becuase I am a novice). I would like when a check box(es) are checked then the code(s) automatically display. I'm not sure  if I'm going about this correct. I have check boxes (named Check Box A, Check BoxB.... ) for all the Symptoms. When a box(es) are checked I want the corrosponding Code(s) to appear below in the text box. How do I automate this with Java Script. See screen grabs. I have attampted to write a script, but it doens't work. The code stays on whether Check BoxA is checked or not. And I don't know how to add script for multiple Codes. Thank you!

I see you still have trouble with this, here is your file uodated with code suplied from try67

just download and it's ready to use.

https://drive.google.com/uc?export=download&id=1oV1X4hvgHNAaoB7HEB8B-WFvbkX5D6SM 

TOPICS
PDF forms

Views

131

Likes

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

Need help with a java script in Adobe Acrobat DC for auto fill text when a check box is selected

New Here ,
Sep 17, 2020

Copy link to clipboard

Copied

Hello-

I am learning how to use prepare forms and I am working on a patient proceedure form for a doctor. I am having trouble with java script (becuase I am a novice). I would like when a check box(es) are checked then the code(s) automatically display. I'm not sure  if I'm going about this correct. I have check boxes (named Check Box A, Check BoxB.... ) for all the Symptoms. When a box(es) are checked I want the corrosponding Code(s) to appear below in the text box. How do I automate this with Java Script. See screen grabs. I have attampted to write a script, but it doens't work. The code stays on whether Check BoxA is checked or not. And I don't know how to add script for multiple Codes. Thank you!

I see you still have trouble with this, here is your file uodated with code suplied from try67

just download and it's ready to use.

https://drive.google.com/uc?export=download&id=1oV1X4hvgHNAaoB7HEB8B-WFvbkX5D6SM 

TOPICS
PDF forms

Views

132

Likes

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
Sep 17, 2020 0
Engaged ,
Sep 17, 2020

Copy link to clipboard

Copied

You can use this code as "Custom Calculation Script" of text field, you can add more checkboxes as needed.
if(this.getField("Check BoxA").value != "Off"){
event.value = "text goes here";}
else if(this.getField("Check BoxB").value != "Off"){
event.value = "text goes here";}
else if(this.getField("Check BoxC").value != "Off"){
event.value = "text goes here";}
else if(this.getField("Check BoxD").value != "Off"){
event.value = "text goes here";}
else if(this.getField("Check BoxE").value != "Off"){
event.value = "text goes here";}
else event.value = "";

Or you can use this code as checkboxes MouseUp event:
this.getField("ICD-10 Code (s)").value = event.target.value != "Off" ? "text goes here" : "";

Likes

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
Reply
Loading...
Sep 17, 2020 0
New Here ,
Sep 17, 2020

Copy link to clipboard

Copied

Hello Nesa and Thank you!

That did work, but it didn't let me add multiple Codes. Also I noticed that if I unckec the box then the corosponding Code does not go away. Can you advise? Thank you Screen Shot 2020-09-17 at 11.09.04 AM.pngScreen Shot 2020-09-17 at 11.11.01 AM.pngagain for your hep and expertise!

 

Likes

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
Reply
Loading...
Sep 17, 2020 0
Engaged ,
Sep 17, 2020

Copy link to clipboard

Copied

If you uncheck the box text field should be empty. Can you share your file?

Also I see you are checking multiple boxes at the same time. What do you want in that case to show in field?

Likes

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
Reply
Loading...
Sep 17, 2020 0
Most Valuable Participant ,
Sep 17, 2020

Copy link to clipboard

Copied

Try this code:

 

var codes = [];
if (this.getField("Check BoxA").valueAsString != "Off")
	codes.push("Code A");
if (this.getField("Check BoxB").valueAsString != "Off")
	codes.push("Code B");
// etc.
event.value = codes.join(", ");

Likes

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
Reply
Loading...
Sep 17, 2020 0
New Here ,
Sep 17, 2020

Copy link to clipboard

Copied

When I uncheck the box it does not clear the "Code" field. Here is my file. And here is the script I have in the ICD-10 field:

if(this.getField("Check BoxA").value != "Off"){
event.value = "M54.2";}
else if(this.getField("Check BoxB").value != "Off"){
event.value = "M54.6";}
else if(this.getField("Check BoxC").value != "Off"){
event.value = "M54.5";}
else if(this.getField("Check BoxD").value != "Off"){
event.value = "M25.551";}
else if(this.getField("Check BoxE").value != "Off"){
event.value = "M25.552";}
else event.value = "";

 

Likes

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
Reply
Loading...
Sep 17, 2020 0
Engaged ,
Sep 17, 2020

Copy link to clipboard

Copied

In your file, Check Box E should be Check BoxE, thats why field won't empty when you uncheck.

For the second part if you want multiple values show at the same time use try67 code that he posted above, if you having trouble let me know il help you with it.

 

Likes

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
Reply
Loading...
Sep 17, 2020 0
New Here ,
Sep 17, 2020

Copy link to clipboard

Copied

Hello and thank you try67

 

I tried to add this code to what I had (see full code below) and that didn't work. I such a beginer I think I am missing a basic step to understand your code. Should I have replaced my previsou code or added this one the the seque

if(this.getField("Check BoxA").value != "Off"){
event.value = "M54.2";}
else if(this.getField("Check BoxB").value != "Off"){
event.value = "M54.6";}
else if(this.getField("Check BoxC").value != "Off"){
event.value = "M54.5";}
else if(this.getField("Check BoxD").value != "Off"){
event.value = "M25.551";}
else if(this.getField("Check BoxE").value != "Off"){
event.value = "M25.552";}
else event.value = "";

if (this.getField("Check BoxA").valueAsString != "Off")
	codes.push("M54.2");
if (this.getField("Check BoxB").valueAsString != "Off")
	codes.push("M54.6");
if (this.getField("Check BoxC").valueAsString != "Off")
	codes.push("M54.5");
if (this.getField("Check BoxD").valueAsString != "Off")
	codes.push("M25.551");
if (this.getField("Check BoxE").valueAsString != "Off")
	codes.push("M25.552");

nce? 

Likes

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
Reply
Loading...
Sep 17, 2020 0
New Here ,
Sep 17, 2020

Copy link to clipboard

Copied

Hello NesaNurani-

Thank you that worked to empty the text box when unchecked. The doctor I am working on this for has just asked if there is a way that the unchecked Symptoms "disapear" from the form to avoid confusion at the radiology clinic. Is this possiable or will I have to rethink my setup here? Would a dropdown with multiple selections enabled be better? And if so would I be able to continue to have a selection autopopulate the below Code section? 

THANK YOU!

Likes

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
Reply
Loading...
Sep 17, 2020 0
Most Valuable Participant ,
Sep 17, 2020

Copy link to clipboard

Copied

This is hardly the code I provided. You should use it instead of the other code you have, and don't remove parts from it (like the last line which actually applies the value to the field...).

Likes

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
Reply
Loading...
Sep 17, 2020 0
Contributor ,
Sep 17, 2020

Copy link to clipboard

Copied

tempsnip.png

You want this text to disapear? What would be conditions for them to disapear?

Likes

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
Reply
Loading...
Sep 17, 2020 0
New Here ,
Sep 17, 2020

Copy link to clipboard

Copied

Ah- I am sorry and now I understand. Appologies and thank you for your patience. No insult was intended!  

Likes

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
Reply
Loading...
Sep 17, 2020 0
Adobe Community Professional ,
Sep 17, 2020

Copy link to clipboard

Copied

The custom calculation script will need to first check the values of all of the related check boxes. I would recommend setting the export value of each check box to the corresponding ICD code. For the check boxes that do not have a value of "Off", add the ICD code to a string that you then set the calculated value to. Post again if you need more help.

Likes

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
Reply
Loading...
Sep 17, 2020 1
New Here ,
Sep 17, 2020

Copy link to clipboard

Copied

Hello George_Johnson

Thank you. I did update the export values of all the check boxes but I'm not sure what to do from here... Appologies, I'm very new to all of this and am seriously thinking of finding a Java Script class!

 

Likes

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
Reply
Loading...
Sep 17, 2020 0
Engaged ,
Sep 17, 2020

Copy link to clipboard

Copied

I see you still have trouble with this, here is your file uodated with code suplied from try67

just download and it's ready to use.

https://drive.google.com/uc?export=download&id=1oV1X4hvgHNAaoB7HEB8B-WFvbkX5D6SM 

Likes

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
Reply
Loading...
Sep 17, 2020 0
New Here ,
Sep 17, 2020

Copy link to clipboard

Copied

Thank you again NesaNurani for your kindness and help with this PDF. I really appreciate your expertise and time. 

Likes

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
Reply
Loading...
Sep 17, 2020 0