14 Replies Latest reply on Jul 17, 2013 8:15 AM by try67

    SyntaxError with form

    mlotobrocks

      I have a drop down that populates a multi-line text field.

      Everything works except on my last paragrah. I can even get it to work if I only include some of the text in this particular paragraph but if I include all I get "SyntaxError: missing } after function body" Anyone have any clue why this would happen? below is my code of it not working:

       

      (function () {

       

          // Do nothing if not committed

          if (event.willCommit) return;

       

          // Set up an array to hold the individual paragraphs of text

          var aQuotes = [];

       

          // Populate the array with the paragraph text

          aQuotes[0] = "FISH study using the target probes described above detected normal copy number for chromosomes 3, 7, 9p21, 17.  No evidence of aneuploidy for chromosomes 3, 7, 17 or deletion of the p16 region of chromosome 9 was found in cells present in this specimen.  However, FISH results alone may not be used to make clinical management decisions. Correlation with results from cytology and other relevant tests is suggested."

          aQuotes[1] = "FISH study using the target probes described above detected copy number for chromosomes 3, 7 and 17 within the normal range for this test. However, three out of 142 urothelial cells analyzed were hyperdiploid for chromosomes 3, 7, 9p21 and 17.  Aneuploidy for chromosomes 3, 7, 9p21 and 17 is associated with urothelial cancer. A repeat specimen is requested for reassurance. FISH results alone may not be used to make clinical management decisions. Correlation with results from cytology and other relevant tests is suggested."

          aQuotes[2] = "FISH study using the target probes described above detected the presence of cells with abnormal copy number of chromosomes 3, 7 and 17.  Aneuploidy for chromosomes 3, 7 and 17 has been reported to be associated with urothelial cancer. However, FISH results alone may not be used to make clinical management decisions.  Correlation with cytology is suggested."

          aQuotes[3] = "FISH study using the target probes described above detected the presence of cells with abnormal copy number of chromosomes 3, 7, 9p21 and 17.  Aneuploidy for chromosomes 3, 7, 9p21 and 17 has been reported to be associated with urothelial cancer. However, FISH results alone may not be used to make clinical management decisions.  Correlation with cytology is suggested."

       

       

          // Get the selected item, which is the export value of the selected combo box item

          var item = event.changeEx

       

          // Display the text corresponding to the selected item in the text field

          getField("paragraph_text").value = aQuotes[item];

       

      })();

       

       

       

      Again if I get rid of aQuotes[3] or if I only include like the first sentence in aQuotes[3] it works.

      Thanks!

        • 1. Re: SyntaxError with form
          MichaelN Level 3

          I am not sure why you are getting a syntax error.

           

          Another way to do it might be the following script:

           

          //Place the following into the custom validation script of your combo box,

          //making sure you tick the option to
          //commit the selected value immediately

           

          var mySel = event.value;
          switch (mySel) {
            case "1":
              this.getField("paragraph_text").value = "Quote 1";
              break;

           

          case "2":
              this.getField("paragraph_text").value = "Quote 2";
              break;

           

          case "3":
              this.getField("paragraph_text").value = "Quote 3";
              break;

           

          case "4":
              this.getField("paragraph_text").value = "Quote 4";
              break;
          }

           

          I hope this helps.

          • 2. Re: SyntaxError with form
            mlotobrocks Level 1

            Thanks for responding. Unfortunatly it's still not working. Here's what I have based on what you sent:

             

            //Place the following into the custom validation script of your combo box,

             

            //making sure you tick the option to

            //commit the selected value immediately

             

             

             

            var mySel = event.value;

            switch (mySel) {

              case "1":

                this.getField("FISH study using the target probes described above detected normal copy number for chromosomes 3, 7, 9p21, 17.  No evidence of aneuploidy for chromosomes 3, 7, 17 or deletion of the p16 region of chromosome 9 was found in cells present in this specimen.  However, FISH results alone may not be used to make clinical management decisions. Correlation with results from cytology and other relevant tests is suggested.").value = "Quote 1";

                break;

             

             

             

            case "2":

                this.getField("FISH study using the target probes described above detected copy number for chromosomes 3, 7 and 17 within the normal range for this test. However, three out of 142 urothelial cells analyzed were hyperdiploid for chromosomes 3, 7, 9p21 and 17.  Aneuploidy for chromosomes 3, 7, 9p21 and 17 is associated with urothelial cancer. A repeat specimen is requested for reassurance. FISH results alone may not be used to make clinical management decisions. Correlation with results from cytology and other relevant tests is suggested.").value = "Quote 2";

                break;

             

             

             

            case "3":

                this.getField("FISH study using the target probes described above detected the presence of cells with abnormal copy number of chromosomes 3, 7 and 17.  Aneuploidy for chromosomes 3, 7 and 17 has been reported to be associated with urothelial cancer. However, FISH results alone may not be used to make clinical management decisions.  Correlation with cytology is suggested.").value = "Quote 3";

                break;

             

             

             

            case "4":

                this.getField("FISH study using the target probes described above detected the presence of cells with abnormal copy number of chromosomes 3, 7, 9p21 and 17.  Aneuploidy for chromosomes 3, 7, 9p21 and 17 has been reported to be associated with urothelial cancer. However, FISH results alone may not be used to make clinical management decisions.  Correlation with cytology is suggested.").value = "Quote 4";

                break;

            }

             

             

            I then get SyntaxError: unterminated string literal

            29: at line 30

             

            (line 30 is that last break;)

            • 3. Re: SyntaxError with form
              try67 MVP & Adobe Community Professional

              This code is fine. It's possible the problem lies somewhere else in your

              file...

              • 4. Re: SyntaxError with form
                try67 MVP & Adobe Community Professional

                PS - You might want to consider renaming your fields to something a bit

                more sensible...

                • 5. Re: SyntaxError with form
                  mlotobrocks Level 1

                  There is something going on. Is it possible that copying the text from Word might be doing something?

                  As with my first attempt if I  include only part of the last paragraph the code works fine, if I include all of the text then I get an error. This is a very small doc (1 page and 9 other text fields beside this dropdown and the target field)

                   

                  This will work (only including part of the last paragraph, I've isolated to where it will work up until):

                   

                  //Place the following into the custom validation script of your combo box,

                   

                  //making sure you tick the option to

                  //commit the selected value immediately

                   

                   

                   

                  var mySel = event.value;

                  switch (mySel) {

                    case "1":

                      this.getField("FISH study using the target probes described above detected normal copy number for chromosomes 3, 7, 9p21, 17.  No evidence of aneuploidy for chromosomes 3, 7, 17 or deletion of the p16 region of chromosome 9 was found in cells present in this specimen.  However, FISH results alone may not be used to make clinical management decisions. Correlation with results from cytology and other relevant tests is suggested.").value = "Quote 1";

                      break;

                   

                   

                   

                  case "2":

                      this.getField("FISH study using the target probes described above detected copy number for chromosomes 3, 7 and 17 within the normal range for this test. However, three out of 142 urothelial cells analyzed were hyperdiploid for chromosomes 3, 7, 9p21 and 17.  Aneuploidy for chromosomes 3, 7, 9p21 and 17 is associated with urothelial cancer. A repeat specimen is requested for reassurance. FISH results alone may not be used to make clinical management decisions. Correlation with results from cytology and other relevant tests is suggested.").value = "Quote 2";

                      break;

                   

                   

                   

                  case "3":

                      this.getField("FISH study using the target probes described above detected the presence of cells with abnormal copy number of chromosomes 3, 7 and 17.  Aneuploidy for chromosomes 3, 7 and 17 has been reported to be associated with urothelial cancer. However, FISH results alone may not be used to make clinical management decisions.  Correlation with cytology is suggested.").value = "Quote 3";

                      break;

                   

                   

                   

                  case "4":

                      this.getField("FISH study using the target probes described above detected the presence of cells with abnormal copy number of chromosomes 3, 7, 9p21 and 17. Aneuploidy for chromosomes 3, 7, 9p21 and 17 has been reported to be associated with urothelial cancer. However, FISH results alone may not be").value = "Quote 4";

                      break;

                  }

                   

                   

                  This does not work when all of that last paragraph is included (even if I type in starting from where it does work instead of copy and paste)

                   

                   

                  //Place the following into the custom validation script of your combo box,

                   

                  //making sure you tick the option to

                  //commit the selected value immediately

                   

                   

                   

                  var mySel = event.value;

                  switch (mySel) {

                    case "1":

                      this.getField("FISH study using the target probes described above detected normal copy number for chromosomes 3, 7, 9p21, 17.  No evidence of aneuploidy for chromosomes 3, 7, 17 or deletion of the p16 region of chromosome 9 was found in cells present in this specimen.  However, FISH results alone may not be used to make clinical management decisions. Correlation with results from cytology and other relevant tests is suggested.").value = "Quote 1";

                      break;

                   

                   

                   

                  case "2":

                      this.getField("FISH study using the target probes described above detected copy number for chromosomes 3, 7 and 17 within the normal range for this test. However, three out of 142 urothelial cells analyzed were hyperdiploid for chromosomes 3, 7, 9p21 and 17.  Aneuploidy for chromosomes 3, 7, 9p21 and 17 is associated with urothelial cancer. A repeat specimen is requested for reassurance. FISH results alone may not be used to make clinical management decisions. Correlation with results from cytology and other relevant tests is suggested.").value = "Quote 2";

                      break;

                   

                   

                   

                  case "3":

                      this.getField("FISH study using the target probes described above detected the presence of cells with abnormal copy number of chromosomes 3, 7 and 17.  Aneuploidy for chromosomes 3, 7 and 17 has been reported to be associated with urothelial cancer. However, FISH results alone may not be used to make clinical management decisions.  Correlation with cytology is suggested.").value = "Quote 3";

                      break;

                   

                   

                   

                  case "4":

                      this.getField("FISH study using the target probes described above detected the presence of cells with abnormal copy number of chromosomes 3, 7, 9p21 and 17. Aneuploidy for chromosomes 3, 7, 9p21 and 17 has been reported to be associated with urothelial cancer. However, FISH results alone may not be used to make clinical management decisions.  Correlation with cytology is suggested.").value = "Quote 4";

                      break;

                  }

                  • 6. Re: SyntaxError with form
                    try67 MVP & Adobe Community Professional

                    Do NOT use Word to write code. It it very likely to create all sorts of

                    problems by inserting special characters, like non-standard quotes. You

                    need to use a plain-text editor, like Notepad. I personally use

                    Notepad++<http://notepad-plus-plus.org/>,

                    and I recommend it highly.

                    • 7. Re: SyntaxError with form
                      Bernd Alheit Adobe Community Professional & MVP

                      You have a field in your form with following name?

                       

                      "FISH study using the target probes described above detected the presence of cells with abnormal copy number of chromosomes 3, 7, 9p21 and 17. Aneuploidy for chromosomes 3, 7, 9p21 and 17 has been reported to be associated with urothelial cancer. However, FISH results alone may not be used to make clinical management decisions.  Correlation with cytology is suggested."

                      • 8. Re: SyntaxError with form
                        mlotobrocks Level 1

                        Yes, I use Coda for codeing.   It's just the paragraph text from the client that is in Word.

                         

                        I just tried retyping in the last paragraph  - no luck

                        retyped last paragraph deleted other 3 - Works!

                         

                        Keeping last and retyping 1st and second - work

                         

                        Keeping retyped 1,2 and 4 retype 3 - Only works until half the paragraph.

                         

                        I'm really stumped here

                        • 9. Re: SyntaxError with form
                          try67 MVP & Adobe Community Professional

                          Can you share the file with us? You can post it to a file-sharing file, or you can send it to me at try6767@gmail.com, and I'll check it out.

                          • 10. Re: SyntaxError with form
                            mlotobrocks Level 1

                            Just sent it to you. Thanks so much for taking a look!

                            • 11. Re: SyntaxError with form
                              Test Screen Name Most Valuable Participant

                              Please answer the question in #7, it's baffling me too.

                              • 12. Re: SyntaxError with form
                                try67 MVP & Adobe Community Professional

                                I can answer... They're not. The file is a bit of a mess...

                                • 13. Re: SyntaxError with form
                                  mlotobrocks Level 1

                                  Thanks for helping!

                                  I had 2 issues it looks like:

                                  1. Field names wrong - I had started off right but when switching to the example code they were way off.

                                  2. Instead of having the code in the Custom keystroke script it's now in validate > Run custom validation script

                                  • 14. Re: SyntaxError with form
                                    try67 MVP & Adobe Community Professional

                                    Also, the values used were the export values instead of the display values.