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

If statement with multiple values

Explorer ,
Feb 02, 2020 Feb 02, 2020

Hi All,

 

I am trying to write an if statement to return a numerical value in a field called "Min" based on the text that is selected in a dropdown box. What I am after is if the dropdown has a value of either KUR1 KUR2 or KUR3 I want the value in the field labelled "Min" to equal 0.5 for anything else I want "Min" to equal 1.0

 

I did have a long line of if statements written, but I am thinking there must be a much better way of doing it!!!!

 

Thank you

LC

 

TOPICS
Edit and convert PDFs
2.0K
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
1 ACCEPTED SOLUTION
Community Expert ,
Feb 03, 2020 Feb 03, 2020

Assuming that this script is in the  custom Validate for the dropdown, here is some code:

 

if((event.value == "KUR1") || (event.value == "KUR2") || (event.value == "KUR3"))

   this.getFiel("Min").value = 0.5;

else

   this.getFiel("Min").value = 1.0;

 

Here is another way to perform the same action

 

switch(event.value)

{

     case "KUR1":

     case "KUR2":

     case "KUR3":

         this.getFiel("Min").value = 0.5;

         break;

     default:

          this.getFiel("Min").value = 1.0;

         break;

}

 

 

 

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

View solution in original post

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 ,
Feb 03, 2020 Feb 03, 2020

Assuming that this script is in the  custom Validate for the dropdown, here is some code:

 

if((event.value == "KUR1") || (event.value == "KUR2") || (event.value == "KUR3"))

   this.getFiel("Min").value = 0.5;

else

   this.getFiel("Min").value = 1.0;

 

Here is another way to perform the same action

 

switch(event.value)

{

     case "KUR1":

     case "KUR2":

     case "KUR3":

         this.getFiel("Min").value = 0.5;

         break;

     default:

          this.getFiel("Min").value = 1.0;

         break;

}

 

 

 

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
Explorer ,
Feb 03, 2020 Feb 03, 2020
LATEST

Hi - thanks for the two ideas. Have used the first option and have it working. Thanks for your help.

 

cheers

LC

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