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

Choice in Dropdown list determines what is put into field box

Community Beginner ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

Hi, 

I am trying to build a timetable in Acrobat DC which depends on the subject that is chosen. So in DD1M (dropdown box) you can choose from a list of subjects "maths", "english" etc. In field "1SM" I can write my own text. So it is a normal text field. 

My problem is the script for "KB". I need a script here with "what if....". If in DD1M "English" is chosen I would like the text from "1SM" to be copied into KB. However, if the choice of the dropdown "DD1M" is "Maths" I would like the text from "1SM" to go in Box KB1 not KB. 

Could someone help me with the script? I am new to this and can't figure it out. 

 

Screenshot 2022-02-08 at 17.16.53.png

TOPICS
JavaScript , PDF forms

Views

493

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 ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

Move your code to be a Calculation script, and change the last line to:

event.value = KB;

Also, you need to declare the KB variable, so add this to the top of your code:

var KB = "";

 

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 Beginner ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

Unfortunately those changes didn't do the trick. The value in KB or KB1 doesnt change at all. So nothing happens, even though I posted it into the calculation script.

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 Beginner ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

Here is a picture of what I changed

Screenshot 2022-02-08 at 21.07.39.png

 

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 ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

What is the name of the dropdown field? 

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 ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

Please check the Console Window (Ctrl-J) for errors. It looks like, as Bernd suggest, the dropdown field name is incorrect in the script (on first line).

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

You must only use straight quotes in your code, not curly ones.

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 ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

Details!! Good catch, and a very common error!!

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 Beginner ,
Feb 09, 2022 Feb 09, 2022

Copy link to clipboard

Copied

LATEST

That's it. It was the curly quotes that sneeked in there. Now its working perfectly. Thank you very very much everyone for helping me with 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 ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

Use calculation scripts at the fields KB and KB1.

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 ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

You can read some general info on Acrobat Form Scripting here:

https://www.pdfscripting.com/public/PDF-Form-Scripting.cfm

And specifically about calculation scripts here:

https://www.pdfscripting.com/public/Calculating-field-values-and-more.cfm

 

Since the action is being driven from a single dropdown. I would suggest using the validation script on the "DD1M" dropdown to set the values  of "KB" and "KB1".  That is, unless the logic on this form is more complex than described. For example, what does the "DD2M" dropdown do?

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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