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

script for drop down choice in one cell, auto populating a separate choice from a different cell

New Here ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

I have a drop down list with several classes listed called "Class 1" (Biology 30, Psychology 30 etc.) in one cell and I have a separate cell called Course 1 that I want the class code to appear. (Biology would be 8255 and Psychology would be 8340, etc) So I want it to recognize the chosen option selection from the drop down list in the first cell (Class 1) and auto-assoicated the choice with the correct choice and place in the second cell (Course 1) - therefore "Biology 30" would be the choice chosen in the first cell and I want the class code associated with Biology "8255" to appear automatically in the Course 1 cell  How do I do this - and is it an Action or Format script?

TOPICS
JavaScript

Views

291

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 ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Give export value to your options in dropdown field, give "Biology" export value "8255" (export value is right under where you add items for dropdown in dropdown field -> properties -> options tab)

and then as calculation script of "Course 1" field use this code:

event.value = this.getField("Class 1").value;

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
New Here ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

LATEST

Got it to work. Thanks so much for your support!

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 ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Another aproach would be to separate out the course code from the complete selection text. For this technique there are no export values. There are several options for doing this, but the easiest is using the split function.  Also, since the value of the course code field is set from a single location, a calculation script is not necessary. You should avoid using calculation scripts whenever possible.  

 

Place this code in the Custom Validation Script for the  drop down field. The code assumes the field in the second cell is named "Course 1".  You'll need to change this to match the field name on your form. 

 

this.getField("Course 1").value = event.value.split(" ").pop();

 

 

 

 

 

 

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