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

Populate Dropdown depending on Radio Button Selection

New Here ,
Oct 14, 2019 Oct 14, 2019

Hey Experts

I have a scenario where I need to the dropdown options to change depending on the selection of a radio button

In my form, I have two Radio buttons and two text boxes

 

When the Yes is ticked, the SelectPackage dropdown options are:

1. B&W Photos & Keyring

2. Color 4x6 Photos & Keyring

3. Color 8x10 Photos & Keyring

4. Other

When the No is ticked, the SelectPackage dropdown options change to below:

1. B&W Photos

2. Color 4x6 Photos

3. Color 8x10 Photos

4. Other

 

I also have a couple of curveballs that I would like.

 

  • If any of the options are 1, 2 or 3, the OtherPackage Textbox is Inactive, but if option 4. Other is selected OtherPackage textbox becomes active
  • If the Radio button Yes is selected, and then option 4 Other is selected OtherPackage textbox becomes active, user types a requirement and when he tabs out, need to concatenate whatever has been typed and & keyring to populate

If the user tries to choose a dropdown selection before selecting a Yes or No, an error message to pop up asking the user to first select one of the radio buttons

 

test1.JPGexpand image

 

I have googled and modified and entered the below code in the Custom calculation script, but it doesn't work

 

//Clear the dropdown displayed value and items
this.rawValue = null;

this.clearItems();

//Repopulate the items based on the radio buttons

if (PacChoice.rawValue == 1)

{

this.addItem("B&W Photos & Keyring");

this.addItem("Color 4x6 Photos & Keyring");

this.addItem("Color 8x10 Photos & Keyring");

this.addItem("Other");

}


else if (PacChoice.rawValue == 2)

{

this.addItem("B&W Photos");

this.addItem("Color 4x6 Photos");

this.addItem("Color 8x10 Photos");

this.addItem("Other");

}

else

{

app.alert("Please select a package option first");

}

 

I am not an expert in javascript, but I tried to get something before asking for help

Your help would be much appreciated

 

Regards

Rahul

 

[Post moved from the Coding Corner wasteland to the Acrobat forum. -Mod.]

1.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
Community Expert ,
Jan 05, 2020 Jan 05, 2020
LATEST

This script is for a LiveCycle form, but it looks like you are using a regular PDF form.

You need to use the Regular Acrobat JavaScript model.

Do you have any experience scripting?

Here's are some links to articles that cover scripting List fields on Acroat Forms.

https://www.pdfscripting.com/public/List-Field-Usage-and-Handling.cfm

https://acrobatusers.com/tutorials/js_list_combo_livecycle/

 

Using the calculation script for this is tricky.  Calculations are run anytime any field on the form is modified and its best not to be contantly changing list items. So you should either filter out changes from any fields except the radio buttons, or use the MouseUp on the radio buttons to make the change.

 

 

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

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