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

Show/Hide based on Dropdown selection with Multiple Choices

Explorer ,
May 18, 2021 May 18, 2021

Copy link to clipboard

Copied

I have a drop down field with loan transfer types listed. There are 13 different options to choose from. I want to be able to select an option from the list and have an additional field show when that option is selected, but hide when it is not. I need to do this for 4 out of the 13 options - and all text fields are different.

 

The dropdown field name is "Amount Override" with options for: None, Loan Payment - Suggested Method, Loan Payment if it exceeds amount, 25% of Loan Payment, 50% of Loan Payment, Loan Due Amount, Loan Due Amount if it exceeds amount, Loan Cycle Balance, Loan Cycle Balance if it exceeds amount, Loan Cycle Balance less credits, Loan Cycle Balance less credits if it exceeds amount, Available Balance, Available Balance in excess of amount.

 

If  None is selected from the dropdown then I want my field that is named "None" to show up - otherwise, I want that to be hidden.

If Loan Payment - Suggested Method is selected from the dropdown then I want my field that is named "LoanPayment" to show up - otherwise, I want that to be hidden.

If Loan Cycle Balance is selected from the dropdown then I want my field that is named "LoanCycleBal" to show up - otherwise, I want that to be hidden.

If Loan Payment if it exceeds amount is selected from the dropdown then I want my field that is named "LoanPaymentExceeds" to show up - otherwise, I want that to be hidden

 

 

I was using the following javascript, but it is hiding the fields no matter what option is selected.

 

if(event.value =="None") {
this.getField("None").display = display.visible;
} else {
this.getField("None").display = display.hidden;
}

if(event.value =="Loan Payment – Suggested Method") {
this.getField("LoanPayment").display = display.visible;
} else {
this.getField("LoanPayment").display = display.hidden;
}

if(event.value =="Loan Payment if it exceeds amount") {
this.getField("LoanPaymentExceeds").display = display.visible;
} else {
this.getField("LoanPaymentExceeds").display = display.hidden;
}

if(event.value =="Loan Cycle Balance") {
this.getField("LoanCycleBal").display = display.visible;
} else {
this.getField("LoanCycleBal").display = display.hidden;
}

 

 

Can someone please help me with this?

TOPICS
Edit and convert PDFs , How to , JavaScript , PDF forms

Views

888

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

correct answers 1 Correct answer

Explorer , May 18, 2021 May 18, 2021

Nesa - I didn't have that box checked, so I checked that and it still wasn't working with what I had.

 

Thom - I went out and found this from the link that you posted and it is working.

 

var nHide = (event.value=="None")?display.visible:display.hidden;

this.getField("None").display = nHide;

var nHide = (event.value=="Loan Payment - Suggested Method")?display.visible:display.hidden;

this.getField("LoanPayment").display = nHide;

var nHide = (event.value=="Loan Cycle Balance ")?display.visible:display.hid

...

Votes

Translate

Translate
Community Expert ,
May 18, 2021 May 18, 2021

Copy link to clipboard

Copied

Read this, it has sample code and explains all.

https://www.pdfscripting.com/public/Hiding-and-Showing-Form-Fields.cfm?sd=40

 

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 ,
May 18, 2021 May 18, 2021

Copy link to clipboard

Copied

In your script, in this line:

if(event.value =="Loan Payment – Suggested Method") {

dash (I marked it red) is not same as  in your dropdown field choice:

Loan Payment - Suggested Method (this is taken from your text so check in your file if it's same.)

other then that your code should work, just make sure in dropdown field properties under 'options' tab check " Commit selected value immediately".

 

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
Explorer ,
May 18, 2021 May 18, 2021

Copy link to clipboard

Copied

LATEST

Nesa - I didn't have that box checked, so I checked that and it still wasn't working with what I had.

 

Thom - I went out and found this from the link that you posted and it is working.

 

var nHide = (event.value=="None")?display.visible:display.hidden;

this.getField("None").display = nHide;

var nHide = (event.value=="Loan Payment - Suggested Method")?display.visible:display.hidden;

this.getField("LoanPayment").display = nHide;

var nHide = (event.value=="Loan Cycle Balance ")?display.visible:display.hidden;

this.getField("Cycle").display = nHide;

var nHide = (event.value=="Loan Payment if it exceeds amount")?display.visible:display.hidden;

this.getField("LoanPaymentExceeds").display = nHide;

var nHide = (event.value=="Loan Due Amount")?display.visible:display.hidden;

this.getField("LoanDueAmt").display = nHide;

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