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

Conditional Logic Issues

New Here ,
Mar 08, 2021 Mar 08, 2021

Copy link to clipboard

Copied

I am creating a form with the following requirements:

  • User chooses "Industry Sector" from drop down list of  8 options
  • Depending on what they chose in "Industry Sector", the field "Production Level" shows a drop down list with up to 7 options for user to choose from.
  • Once user chooses "Production Level" the text field "Suggested Contribution" is automatically calculated.

I have the Industry Sector and Production Level fields working as expected, however, I cannot get the right data to show in the "Suggested Contribution" field. Here is the script that I have in the "Validate" area of the "Production Level" field:

 

switch (event.value) {

case "<1,000 acres":

this.getField("Suggested Contribution").value = 250.00;

case "1,001 - 100,000 acres":

this.getField("Suggested Contribution").value = 750.00;

case "100,001 - 500,000 acres":

this.getField("Suggested Contribution").value = 1500.00;

case ">500,001 acres":

this.getField("Suggested Contribution").value = 3000.00;

case "<10 MMBFT/YR":

this.getField("Suggested Contribution").value = 600.00;

case "10.1 - 20 MMBFT/YR":

this.getField("Suggested Contribution").value = 1200.00;

case "20.1 – 30 MMBFT/YR":

this.getField("Suggested Contribution").value = 3000.00;

case "+30 MMBFT/YR":

this.getField("Suggested Contribution").value = 6000.00

}

 

These are not the only options, but I want to get it working correctly before adding the others, any help on why this is not working correctly? Appreciate it in advance!

 

TOPICS
How to , PDF forms

Views

870

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

Community Expert , Mar 08, 2021 Mar 08, 2021

Add a "break;" command at the end of each case.

Votes

Translate

Translate
Community Expert ,
Mar 08, 2021 Mar 08, 2021

Copy link to clipboard

Copied

Add a "break;" command at the end of each case.

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

Copy link to clipboard

Copied

Ahhh! That helped, thank you so much! Now how do I get it to update "Live"? Here is what is happening:

I choose " Forestry" in the Industry Sector drop down

Then I choose "1,001 - 100,000 acres" in the Production Level drop down. The correct amount shows in the Suggested Contribution Field. However, if I change my mind, and go back and adjust the Production Level to a different choice, the "Suggested contribution" does not change automatically, I have to click in that field in order for it to update. Can I get it to update as I make different choices?

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

Copy link to clipboard

Copied

Go to the Properties of the drop-down field, and under Options tick the "Commit selected values immediately" box.

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

Copy link to clipboard

Copied

PS. If the prices are unique for each option in the drop-down menu there's a much easier way to do it.

Simply apply those numbers as the export value of each option and then all you'll need to do is use the following as the custom calculation script of "Suggested Contribution":

 

event.value = this.getField("Production Level").valueAsString;

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

Copy link to clipboard

Copied

Thank you so much, now working as expected, I genuinely appreciate the help!

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

Copy link to clipboard

Copied

One more question, I hope you can help. I now want to add another text field "Suggested Monthly Contribution". This will only populate in 9 instances, all others should show "NA".  I know I can add this.getField ("Suggested Monthly Contribution").value = 50 or whatever number I want, but how do I get it to show NA for those instances where there we do not accept montly contributions, only annual?

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

Copy link to clipboard

Copied

If you're using the same code as before (with the switch command), add a default clause to the end of it, like this:

 

default:

this.getField("Suggested Contribution").value = "N/A";

 

Since this is the last item you don't need to add "break" to it.

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

Copy link to clipboard

Copied

Perfect, thanks so much, working great, and really happy with the end results. Appreciate all your help!

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

Copy link to clipboard

Copied

Hoping you can help. I created the attached form, and it seemed to be working fine. However, once I saved it and then opened it only as a pdf, the custom validation script for Industry Sector does not seem to be working, it only shows "Select One" in the secondary "Production Level" field. If I open it to edit as a form in Adobe Acrobat and then preview, it works, but when saved just as a pdf, it is not working. Any suggestions?

 

Thank you!

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

Copy link to clipboard

Copied

It's working fine for me. Where are you opening it, exactly? And what "preview" are you referring to?

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

Copy link to clipboard

Copied

When I just open it in Adobe Acrobat Pro DC, I can choose the "Industry Sector" but it does not populate the "Production Level" field. If I then go to "Create Form" and choose the same file, it opens with editing capabilities and if I hit "Preview" it works correctly. When I then save it and reopen it, the Industry Sector does not push the info to the other fields. Ugh!

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

Copy link to clipboard

Copied

LATEST

Works fine for me...

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