23 Replies Latest reply on Feb 23, 2016 10:45 PM by try67

    is this format possible?

    marka9619111

      Change the value of a drop down list depending on 2 check box options

            A OR B OR C  (NOT "AND")

           Then check box 1 OR 2 OR 3  (NOT "AND")

                Drop down  X1 OR X2 OR X3 options selected have new value

       

      Check box A = yes

         Check Box 1 = yes

         or - Check Box 2 = yes

         or - Check box 3 = yes

           Drop down selections in X1 or X2 or X3  have new values

      or - Check box B = yes

         Check Box 1 = yes

         or - Check Box 2 = yes

         or - Check box 3 = yes

           Drop down selections in X1, X2 or X3  have new values

      or - Check box C = yes

         Check Box 1 = yes

         or - Check Box 2 = yes

         or - Check box 3 = yes

           Drop down selections in X1, X2 or X3  have new values

       

      Box A==yes    Box 1==yes   drop down X1 selected value is 1010    new value = 1000

      Box B==yes    Box 1==yes   drop down X1 selected value is 1010    new value = 750

      Box A==yes    Box 2==yes   drop down X3 selected value is 2020    new value = 500

       

      Here is a sample of the (long)  'else if' and 'event.value' script with the unknown errors (although the copy and paste made some odd changes here I have tried to remove)

       

       

       

      if (ySR=="yes"){

       

           if (xCX==”yes”){

       

                if (zIN=="001"){event.value = 00             

       

                }else if (zIN==”1010”){event.value = 1200

       

           }else if (zIN==”1020”){event.value = 2100

       

           }else if (zIN==”1030”){event.value = 3000

       

      else if (xDS=”yes”){

       

           if (zIN=="001"){event.value = 00

       

           }else if (zIN==”1010”){event.value = 800

       

           }else if (zIN==”1020”){event.value = 1500

       

           }else if (zIN==”1030”){event.value = 2100

          }

       

      else if (xNP=”yes”){

       

           if (zIN=="001"){event.value = 00

       

           }else if (zIN==”1010”){event.value= 450

       

           }else if (zIN==”1020”){event.value = 800

       

           }else if (zIN==”1030”){event.value = 1500  }

       

      else if (xFM=”yes”){

       

           if (zFarm=="002") {event.value = 00

       

           }else if (zFarm==”11010”){event.value = 250

       

           }else if (zFARM==”11020”){event.value = 4500

       

           }else if (zFARM==”11030”){event.value = 500  }

       

      else if (xTH=”yes”){

       

           if (zIN=="001"){event.value = 00   

       

           }else if (zIN==”1010”){event.value = 1150

       

           }else if (zIN==”1020”){event.value = 2100

       

           }else if (zOUT=="003") {event.value = 00

       

           }else if (zOUT==”1515”){event.value = 400

       

           }else if (zOUT==”1530”){event.value = 6500 

       

           }else if (zOUT==”1545”){event.value = 1000

       

           }else if (zOUT==”1560”){event.value = 1200

       

           }else if (zOUT==”3030”){event.value = 1550

       

           }else if (zOUT==”3045”){event.value = 2200

       

           }else if (zOUT==”3060”){event.value = 3200  }

       

      else if (xEV=”yes”){

       

           if (zIN=="001"){event.value = 00

       

           }else if (zIN==”1010”){event.value = 1150

       

           }else if (zIN==”1020”){event.value = 2100

       

           }else if (zOUT=="003") {event.value = 00

       

           }else if (zOUT==”1515”){event.value = 600

       

           }else if (zOUT==”1530”){event.value = 11500 

       

           }else if (zOUT==”1545”){event.value = 1250

       

           }else if (zOUT==”1560”){event.value = 1550

       

           }else if (zOUT==”3030”){event.value = 1550

       

           }else if (zOUT==”3045”){event.value = 2400

       

           }else if (zOUT==”3060”){event.value = 2800

       

           }else if (ySR==”no”){

       

       

       

      }else if (ySC=”yes”){

       

      if (xCX=”yes”){

       

           if (zIN=="001") {event.value = 00

       

           }else if (zIN==”1010”){event.value = 1500

       

           }else if (zIN==”1020”){event.value = 2750

       

           }else if (zIN==”1030”){event.value = 3600

       

           }else if (zIN==”1040”){event.value = 4400

       

           }else if (zIN==”2020”){event.value = 4000

       

           }else if (zIN==”400”){event.value = 3750  }

       

      else if (xDS=”yes”){

       

           if (zIN=="001") {event.value = 00

       

           }else if (zIN==”1010”){event.value = 850

       

           }else if (zIN==”1020”){event.value = 1700

       

           }else if (zIN==”1030”){event.value = 2500

       

           }else if (zIN==”1040”){event.value = 3200

       

           }else if (zIN==”2020”){event.value = 3750

       

           }else if (zIN==”400”){event.value = 3250  }

       

      else if (xNP=”yes”){

       

           if (zIN=="001") {event.value = 00

       

           }else if (zIN==”1010”){event.value = 500

       

           }else if (zIN==”1020”){event.value = 850

       

           }else if (zIN==”1030”){event.value = 1200  }

       

      else if (xFM=”yes”){

       

           if (zFarm=="002") {event.value = 00

       

           }else if (zFarm==”11010”){event.value= 300

       

           }else if (zFARM==”11020”){event.value = 5500 

       

           }else if (zFARM==”11030”){event.value = 750  }

       

      else if (xTH=”yes”){

       

           if (zIN=="001") {event.value = 00

       

           }else if (zIN==”1010”){event.value = 1250

       

           }else if (zIN==”1020”){event.value = 2250

       

           }else if (zOUT=="003") {event.value = 00

       

           }else if (zOUT==”1515”){event.value = 500

       

           }else if (zOUT==”1530”){event.value = 8500 

       

           }else if (zOUT==”1545”){event.value = 1250

       

           }else if (zOUT==”1560”){event.value = 1600

       

           }else if (zOUT==”3030”){event.value = 1600

       

           }else if (zOUT==”3045”){event.value = 2100

       

           }else if (zOUT==”3060”){event.value = 3250  }

       

      else if (xEV=”yes”){

       

           if (zIN=="001") {event.value = 00

       

           }else if (zIN==”1010”){event.value = 1250

       

           }else if (zIN==”1020”){event.value = 2250

       

           }else if (zOUT=="003") {event.value = 00

       

           }else if (zOUT==”1515”){event.value = 650

       

           }else if (zOUT==”1530”){event.value = 10500 

       

           }else if (zOUT==”1545”){event.value = 1250

       

           }else if (zOUT==”1560”){event.value = 1550

       

           }else if (zOUT==”3030”){event.value = 1750

       

           }else if (zOUT==”3045”){event.value = 2750

       

           }else if (zOUT==”3060”){event.value = 3250

       

           }else if (ySC==”no”){

       

       

       

      }else if (y2SS=”yes”){

       

      if (xCX=”yes”){

       

           if (zIN=="001") {event.value = 00

       

           }else if (zIN==”1010”){event.value = 2500

       

           }else if (zIN==”1020”){event.value = 4500

       

           }else if (zIN==”1030”){event.value = 6300

       

           }else if (zIN==”1040”){event.value = 8000

       

           }else if (zIN==”2020”){event.value = 7250

       

           }else if (zIN==”400”){event.value = 65000  }

       

      else if (xDS=”yes”){

       

           if (zIN=="001") {event.value = 00

       

           }else if (zIN==”1010”){event.value = 1500

       

           }else if (zIN==”1020”){event.value = 3000

       

           }else if (zIN==”1030”){event.value = 4400

       

           }else if (zIN==”1040”){event.value = 5750

       

           }else if (zIN==”2020”){event.value = 6250

       

           }else if (zIN==”400”){event.value = 5750  }

       

      else if (xNP=”yes”){

       

           if (zIN=="001") {event.value = 00

       

           }else if (zIN==”1010”){event.value = 900

       

           }else if (zIN==”1020”){event.value = 1650

       

           }else if (zIN==”1030”){event.value = 2400  }

       

      else if (xFM=”yes”){

       

           if (zFarm=="002") {event.value = 00

       

           }else if (zFarm==”11010”){event.value = 550

       

           }else if (zFARM==”11020”){event.value = 500

       

           }else if (zFARM==”11030”){event.value = 1100  }

       

      else if (xTH=”yes”){

       

           if (zIN=="001") {event.value = 00

       

           }else if (zIN==”1010”){event.value = 2000

       

           }else if (zIN==”1020”){event.value = 4000

       

           }else if (zOUT=="003") {event.value = 00

       

           }else if (zOUT==”1515”){eventvalue = 750

       

           }else if (zOUT==”1530”){event.value = 140500

       

           }else if (zOUT==”1545”){event.value = 2000

       

           }else if (zOUT==”1560”){event.value = 2500

       

           }else if (zOUT==”3030”){event.value = 2750

       

           }else if (zOUT==”3045”){event.value = 3750

       

           }else if (zOUT==”3060”){event.value = 4800  }

       

      else if (xEV=”yes”){

       

           if (zIN=="001") {event.value = 00

       

           }else if (zIN==”1010”){event.value = 2000

       

           }else if (zIN==”1020”){event.value = 4000

       

           }else if (zOUT=="003") {event.value = 00

       

           }else if (zOUT==”1515”){event.value = 1100

       

           }else if (zOUT==”1530”){event.value = 20500

       

           }else if (zOUT==”1545”){event.value = 2500

       

           }else if (zOUT==”1560”){event.value = 3000

       

           }else if (zOUT==”3030”){event.value = 3000

       

           }else if (zOUT==”3045”){event.value = 4750

       

           }else if (zOUT==”3060”){event.value = 5200  }

       

        • 1. Re: is this format possible?
          try67 MVP & Adobe Community Professional

          What errors are you getting when the code executes?

          Also, in the code above you're using non-standard quotation marks, which will cause an error if that's what you're using in your actual code.

          I have a feeling you're using something like Word to write your code. If that's the case it's a big mistake. Only use plain-text editors.
          I recommend using Notepad++.

          • 2. Re: is this format possible?
            try67 MVP & Adobe Community Professional

            Also, you're making the classic mistake of using the assignment operator (=) instead of the comparison operator (==) in your if-statements.

            So this:

            if (xTH=”yes”)

            Should be:

            if (xTH=="yes")

            • 3. Re: is this format possible?
              marka9619111 Level 1

              You are correct - that was from word, I'll switch to note bad and change the = to =='s

              I'll be back. I'm sure, another note, would it be better to use 3 "hidden" text fields then use them to calc the values?

              this will be used as a fillable pdf form in acrobat (however I'd love to publish it as a page on my (wix) website

              • 4. Re: is this format possible?
                marka9619111 Level 1

                Syntax Error; missing } in compound statement

                158: at line 159

                 

                which seems to be at the very end,

                • 5. Re: is this format possible?
                  Test Screen Name Most Valuable Participant

                  Your code certainly seems to missing a lot of them. Suggest you print out and mark them up in pairs. It's what I do when the braces have got out of balance.

                  • 6. Re: is this format possible?
                    marka9619111 Level 1

                    Missing "Them"? as in Braces?

                    Should it read {event.value = 500 }

                    or

                    {event.value} = 500

                    ??

                    I see an { and an } for each line of script

                    • 7. Re: is this format possible?
                      try67 MVP & Adobe Community Professional

                      The former.

                       

                      If you're using Notepad++ It will highlight matching brackets, and also you'll be able to easily count them, to make sure you have the same number of opening and closing ones.

                      • 8. Re: is this format possible?
                        try67 MVP & Adobe Community Professional

                        Hidden fields? What for?

                        • 9. Re: is this format possible?
                          marka9619111 Level 1

                          might help eliminate an 'else if' statement or value of an operation

                          • 10. Re: is this format possible?
                            marka9619111 Level 1

                            Oh and by the way....

                            I hope your having a great day.

                            I really appreciate your help

                            • 11. Re: is this format possible?
                              Test Screen Name Most Valuable Participant

                              You may be looking only for them on each line, but you have some extra { which start groups, but no } to close them. I really suggest you go over your code trying to pair them up. They must be paired, but can take hundreds of lines to do that.

                              • 12. Re: is this format possible?
                                marka9619111 Level 1

                                Good Morning,

                                So here I go again...

                                -Ive had some coffee and aspirin and bought a couple books

                                -Changed all the '='s to '=="s

                                -used the 'notepad++' to pair the braces an general formatting / MUCH easier!

                                 

                                I shortened the form and eliminated a lot of  ' else if '  statements for brevity, but they will need to be added back in (I found the '.txt' paste very difficult to read, so this was copied from word)

                                 

                                So here is where I'm at (first error  it error) and still getting an error in Adobe X Pro, pdf forms, text field, custom calculation script,

                                   SyntaxError; missing ; before statement  5: at line 6

                                • 13. Re: is this format possible?
                                  try67 MVP & Adobe Community Professional

                                  You need to post your code for additional help.

                                  By the way, when using Notepad++ make sure you go to Language and set it to JavaScript. It will help you a lot with correctly formatting and writing your code.

                                  DO NOT USE WORD! I can't stress this enough. You're shooting yourself in the foot by doing so.

                                  • 14. Re: is this format possible?
                                    marka9619111 Level 1

                                    Here is the code from notepad++, but I find it hard to read when pasted here ( that's why 'thought' I had pasted the word. rtf )

                                     

                                    if (ySR=="yes"){
                                    if (xCX=="yes"){
                                      if (zIN=="1010"){event.value = 1200;}
                                      else if (zIN=="1020"){event.value = 2100;}
                                      else (xCX=="no") {event.value=0;}}
                                    else if (xDS=="yes"){
                                      if (zIN=="1010"){event.value = 800;}
                                      else if (zIN=="1020"){event.value = 1500;}
                                      else (xDS=="no") {event.value=0;}}
                                    else if (xNP=="yes"){
                                      if (zIN=="1010"){event.value= 450;}
                                      else if (zIN=="1020"){event.value = 800;}
                                      else (xNP=="no") {event.value=0;}}
                                    else (ySR=="no") {event.value=0;}}

                                     

                                    else if (ySC=="yes"){
                                    if (xCX=="yes"){
                                      if (zIN=="1010"){event.value = 1500;}
                                      else if (zIN=="1020"){event.value = 2750;}
                                       else (xCX=="no") {event.value=0;}}
                                    else if (xDS=="yes"){
                                      if (zIN=="1010"){event.value = 850;}
                                      else if (zIN=="1020"){event.value = 1700;}
                                       else (xDS=="no") {event.value=0;}}
                                    else if (xEV=="yes"){
                                      if (zIN=="1010"){event.value = 1250;}
                                      else if (zIN=="1020"){event.value = 2250;}
                                       else (xEV=="no") {event.value=0;}}
                                    else (ySC=="no"){event.value=0;}}

                                     

                                    else (y2SS=="yes") {
                                    if (xCX=="yes"){
                                      if (zIN=="1010"){event.value = 2500;}
                                      else if (zIN=="1020"){event.value = 4500;}
                                      else (xCX=="no") {event.value=;0}}
                                    else if (xDS=="yes"){
                                      if (zIN=="1010"){event.value = 1500;}
                                      else if (zIN=="1020"){event.value = 3000;}
                                      else (xDS=="no") {event.value=0;}}
                                    else if (xNP=="yes"){
                                      if (zIN=="1010"){event.value = 900;}
                                      else if (zIN=="1020"){event.value = 1650;}
                                      else (xNP=="no") {event.value=0;}}
                                    else (y2SS=="no"){event.value=0;}}

                                    • 15. Re: is this format possible?
                                      try67 MVP & Adobe Community Professional

                                      The problem is with this line (and all similar lines, of course):

                                      else (xCX=="no") {event.value=0;}}

                                      It should be:

                                      else if (xCX=="no") {event.value=0;}}

                                      • 16. Re: is this format possible?
                                        marka9619111 Level 1

                                        So I changed the ' else ' to all  ' else if ' and ran it again, now I get

                                           Syntax error: syntax error 35: at line 36

                                         

                                        if (ySR=="yes"){
                                        if (xCX=="yes"){
                                          if (zIN=="1010"){event.value = 1200;}
                                          else if (zIN=="1020"){event.value = 2100;}
                                          else if (xCX=="no") {event.value=0;}}
                                        else if (xDS=="yes"){
                                          if (zIN=="1010"){event.value = 800;}
                                          else if (zIN=="1020"){event.value = 1500;}
                                          else if (xDS=="no") {event.value=0;}}
                                        else if (xNP=="yes"){
                                          if (zIN=="1010"){event.value= 450;}
                                          else if (zIN=="1020"){event.value = 800;}
                                          else if (xNP=="no") {event.value=0;}}
                                        else if (ySR=="no") {event.value=0;}}

                                        else if (ySC=="yes"){
                                        if (xCX=="yes"){
                                          if (zIN=="1010"){event.value = 1500;}
                                          else if (zIN=="1020"){event.value = 2750;}
                                           else if (xCX=="no") {event.value=0;}}
                                        else if (xDS=="yes"){
                                          if (zIN=="1010"){event.value = 850;}
                                          else if (zIN=="1020"){event.value = 1700;}
                                           else if (xDS=="no") {event.value=0;}}
                                        else if (xEV=="yes"){
                                          if (zIN=="1010"){event.value = 1250;}
                                          else if (zIN=="1020"){event.value = 2250;}
                                           else if (xEV=="no") {event.value=0;}}
                                        else if (ySC=="no"){event.value=0;}}

                                        else if (y2SS=="yes") {
                                        if (xCX=="yes"){
                                          if (zIN=="1010"){event.value = 2500;}
                                          else if (zIN=="1020"){event.value = 4500;}
                                              else if (xCX=="no") {event.value=;0}}
                                        else if (xDS=="yes"){
                                          if (zIN=="1010"){event.value = 1500;}
                                          else if (zIN=="1020"){event.value = 3000;}
                                              else if (xDS=="no") {event.value=0;}}
                                        else if (xNP=="yes"){
                                          if (zIN=="1010"){event.value = 900;}
                                          else if (zIN=="1020"){event.value = 1650;}
                                              else if (xNP=="no") {event.value=0;}}
                                        else if (y2SS=="no"){event.value=0;}}

                                        • 17. Re: is this format possible?
                                          try67 MVP & Adobe Community Professional

                                          In Notepad++ you'll see the line numbers on the left. Go to line 35 of your

                                          code and look at it carefully. Also check the line before and after for

                                          anything weird...

                                           

                                          On Tue, Feb 23, 2016 at 10:02 PM, marka9619111 <forums_noreply@adobe.com>

                                          • 18. Re: is this format possible?
                                            marka9619111 Level 1

                                            so this went through without errors (replaced a  ' : ' with a ' ; ' )

                                            but it still wont bring up a calc total in the text field

                                             

                                            if (ySR=="yes"){
                                            if (xCX=="yes"){
                                              if (zIN=="1010"){event.value = 1200;}
                                              else if (zIN=="1020"){event.value = 2100;}
                                              else if (xCX=="no") {event.value=0;}}
                                            else if (xDS=="yes"){
                                              if (zIN=="1010"){event.value = 800;}
                                              else if (zIN=="1020"){event.value = 1500;}
                                              else if (xDS=="no") {event.value=0;}}
                                            else if (xNP=="yes"){
                                              if (zIN=="1010"){event.value= 450;}
                                              else if (zIN=="1020"){event.value = 800;}
                                              else if (xNP=="no") {event.value=0;}}
                                            else if (ySR=="no") {event.value=0;}}

                                            else if (ySC=="yes"){
                                            if (xCX=="yes"){
                                              if (zIN=="1010"){event.value = 1500;}
                                              else if (zIN=="1020"){event.value = 2750;}
                                               else if (xCX=="no") {event.value=0;}}
                                            else if (xDS=="yes"){
                                              if (zIN=="1010"){event.value = 850;}
                                              else if (zIN=="1020"){event.value = 1700;}
                                               else if (xDS=="no") {event.value=0;}}
                                            else if (xEV=="yes"){
                                              if (zIN=="1010"){event.value = 1250;}
                                              else if (zIN=="1020"){event.value = 2250;}
                                               else if (xEV=="no") {event.value=0;}}
                                            else if (ySC=="no"){event.value=0;}}

                                            else if (y2SS=="yes") {
                                            if (xCX=="yes"){
                                              if (zIN=="1010"){event.value = 2500;}
                                              else if (zIN=="1020"){event.value = 4500;}
                                              else if (xCX=="no") {event.value=0;}}
                                            else if (xDS=="yes"){
                                              if (zIN=="1010"){event.value = 1500;}
                                              else if (zIN=="1020"){event.value = 3000;}
                                              else if (xDS=="no") {event.value=0;}}
                                            else if (xNP=="yes"){
                                              if (zIN=="1010"){event.value = 900;}
                                              else if (zIN=="1020"){event.value = 1650;}
                                              else if (xNP=="no") {event.value=0;}}
                                            else if (y2SS=="no"){event.value=0;}}

                                            • 19. Re: is this format possible?
                                              try67 MVP & Adobe Community Professional

                                              So now you need to debug it. Start by printing the values of the variables to the console and check if they're what you expect them to be.
                                              And keep in mind that JS is case-sensitive...

                                              • 20. Re: is this format possible?
                                                marka9619111 Level 1

                                                I get a repetitive

                                                ySR is not defined

                                                1:AcroForm:All:Calculate

                                                ReferenceError: ySR is not defined

                                                 

                                                so where/how do I define the ySR check box?

                                                • 21. Re: is this format possible?
                                                  try67 MVP & Adobe Community Professional

                                                  You have to define a variable with that name (I had assumed you did that until now)... If this is the name of a field then you can do it like this:

                                                  var ySR = this.getField("ySR").value;

                                                  • 22. Re: is this format possible?
                                                    marka9619111 Level 1

                                                    do I place that on each line with a separate field or can I run a single line with each field it will ask me to get?

                                                    • 23. Re: is this format possible?
                                                      try67 MVP & Adobe Community Professional

                                                      You only need to declare it once.