9 Replies Latest reply on Mar 12, 2011 9:39 AM by ARTIrecruiter

    Syntax Error Unterminated String Literal

    ARTIrecruiter

      I am getting a Syntax Error Unterminated String Literal 15: at line 15

       

      I have the the following radio buttons set up

       

      Medical (Name)

           SS (Radio Button Choice)

           SEC

           SES

           SF

           SDC

       

       

      Medical

      A) Standard Carefirst (12) BCBS Medical

      10) Single $ 44.00

      11) Employee & Child(ren) $ 82.00

      12) Employee & Spouse $ 99.00

      13) Family $125.00

      14) Decline Coverage $0.00    Choice____    Amount____

       

      In my mind when a person selects the radio button beside "Single",  Choice: will be 10. (Choice is a text field, so this is where I enter the custom script).

       

      This works fine until line 16 is entered into the Custom Calculation script:

       

      Medical = this.getField("Medical").value;

       

      if (Medical == "SS") {

       

      event.value = 10;

       

      } else if (Medical == "SEC") {

       

      event.value = 11;

       

      } else if (Medical == "SES") {

       

      event.value = 12;

       

      } else if (Medical == "SF”)  {

       

      event.value = 13;

       

      } else if (Medical == "SDC") {

       

      event.value = 14}

      Thanks in advance for any help!

        • 1. Re: Syntax Error Unterminated String Literal
          George_Johnson MVP & Adobe Community Professional

          The problem is this line:

           

          } else if (Medical == "SF”)  {

           

           

          The quote mark after the F is not the right type. Replace it with the one before the S and it will be OK.

          1 person found this helpful
          • 2. Re: Syntax Error Unterminated String Literal
            ARTIrecruiter Level 1

            Hey thanks for the quick response.

             

            I changed the quote to match on both sides of SF but now the string does not work at all.

             

            I've deleted it and retyped the entire string just to make sure everything matches and I still do not get any results.

            • 3. Re: Syntax Error Unterminated String Literal
              try67 MVP & Adobe Community Professional

              Post your new code. You might have a new problem.

              • 4. Re: Syntax Error Unterminated String Literal
                ARTIrecruiter Level 1

                I started over with the code and it finally started working

                 

                 

                Medical

                A) Standard Carefirst (12) BCBS Medical

                10) Single $ 44.00

                11) Employee & Child(ren) $ 82.00

                12) Employee & Spouse $ 99.00

                13) Family $125.00

                14) Decline Coverage $0.00                Choice:           Amount:$

                 

                 

                code in Choice

                 

                 

                Medical = this.getField("Medical").value;

                 

                if (Medical == "SS") {

                 

                event.value = 10;

                 

                } else if (Medical == "SEC") {

                 

                event.value = 11;

                 

                } else if (Medical == "SES") {

                 

                event.value = 12;

                 

                } else if (Medical == "SF") {

                 

                event.value = 13;

                 

                }else if (Medical == "SDC") {

                 

                event.value = 14;

                 

                }

                 

                 

                code in Amount:$

                 

                 

                Choice = this.getField("Choice").value;

                 

                if (Choice == "10") {

                 

                event.value = 44.00;

                 

                } else if (Choice == "11") {

                 

                event.value = 82.00;

                 

                } else if (Choice == "12") {

                 

                event.value = 99.00;

                 

                } else if (Choice == "13") {

                 

                event.value = 125.00;

                 

                }else if (Choice == "14") {

                 

                event.value = 0.00;

                 

                }

                 

                However it is not working properly is with these options

                B) Premium Carefirst (06) BCBS Medical

                10) Single $ 80.00

                11) Employee & Child(ren) $146.00

                12) Employee & Spouse $161.00

                13) Family $188.00

                14) Decline Coverage                     $0.00 Choice:           Amount:$

                 

                code  in Choice

                 

                Medical = this.getField("Medical").value;

                 

                if (Medical == "PS") {

                 

                event.value = 10;

                 

                } else if (Medical == "PEC") {

                 

                event.value = 11;

                 

                } else if (Medical == "PES") {

                 

                event.value = 12;

                 

                } else if (Medical == "PF") {

                 

                event.value = 13;

                 

                }else if (Medical == "PDC") {

                 

                event.value = 14;

                 

                }

                 

                 

                code in Amount: $

                 

                 

                Choice_2 = this.getField("Choice_2").value;

                 

                if (Choice_2 == "10") {

                 

                event.value = 80.00;

                 

                } else if (Choice_2 == "11") {

                 

                event.value = 146.00;

                 

                } else if (Choice_2 == "12") {

                 

                event.value = 161.00;

                 

                } else if (Choice_2 == "13") {

                 

                event.value = 188.00;

                 

                }else if (Choice_2 == "14") {

                 

                event.value = 0.00;

                 

                }

                 

                When I click the radio button for Single $80.00, the value in Choice is 10 Amount is $161
                When I click the radio button for Employee & Child(ren) $146.00, the value in Choice is 11 Amount is $80
                When I click the radio button for Employee & Spouse $161.00, the value in Choice is 12 Amount is $146
                When I click the radio button for Employee & Family $188.00, the value in Choice is 13 Amount is $161
                When I click the radio button for Decline Coverage $0.00, the value in Choice is 14 Amount is $188

                 

                 

                Message was edited by: ARTIrecruiter

                • 5. Re: Syntax Error Unterminated String Literal
                  George_Johnson MVP & Adobe Community Professional

                  To make things easier to follow and help minimize errors, you might want to structure the code as shown below. Also, be sure to set the field calculation order to whatever makes sense for your form.

                   

                  //Custom Calculate script
                  (function () {
                  
                      var Medical = getField("Medical").value;
                  
                      switch (Medical) {
                      case "SS" : event.value = 10; break;
                      case "SEC": event.value = 11; break;
                      case "SES": event.value = 12; break;
                      case "SF" : event.value = 13; break;
                      case "SDC": event.value = 14; break;
                      default: event.value = "";
                      }
                  
                  })();
                  
                  • 6. Re: Syntax Error Unterminated String Literal
                    ARTIrecruiter Level 1

                    The issue was my field calculation order!!

                     

                    Thanks!!

                     

                    This form is almost in working order.

                     

                    I have one more tiny issue.

                     

                    I used radio buttons specifically for Medical because an employee can only elect one type of medical coverage.

                     

                    The issue I see with the form now is if I click the radio button beside Standard Single $44.00; Choice:10 and Amount:$ 44.00 (that's perfect)

                     

                    If I change my mind and I click the radio button beside Premium Employee & Child(ren); Choice: 11 and Amount: $146.00 (that's perfect)

                     

                    However the value in the Standard Choice & Amount do not reset to $0.00 they remain at Choice: 10 and Amount $44.00; even though the radio button selected for those amounts is no longer my choice of medical coverage. Meaning the person has selected a medical coverage from both Standard and Premium.

                     

                    Is there a code that will reset the values in Medical Standard or Premium based on the employee's choice between the two coverages?

                     

                    Thanks in advance!!

                     

                    Jason

                    • 7. Re: Syntax Error Unterminated String Literal
                      George_Johnson MVP & Adobe Community Professional

                      I'm a bit confused because it seems as though you're getting the value of the "Medical" field in both the Standard and Premium scripts. Is that correct? What is the name of the Standard radio button group, and what is the name of the Premium group?

                      1 person found this helpful
                      • 8. Re: Syntax Error Unterminated String Literal
                        ARTIrecruiter Level 1

                        George,

                         

                        Disregard my question, I used the code you suggested and the issue I was having is gone! 

                         

                        Wow a million times over!!

                         

                        -Jason

                        • 9. Re: Syntax Error Unterminated String Literal
                          ARTIrecruiter Level 1

                          (function () {

                           

                              var Medical = getField("Medical").value;

                           

                              switch (Medical) {

                              case "SS" : event.value = 10; break;

                              case "SEC": event.value = 11; break;

                              case "SES": event.value = 12; break;

                              case "SF" : event.value = 13; break;

                              case "SDC": event.value = 14; break;

                              default: event.value = "14";

                              }

                           

                          })();

                           

                           

                          (function () {

                           

                              var Medical = getField("Medical").value;

                           

                              switch (Medical) {

                              case "PS" : event.value = 10; break;

                              case "PEC": event.value = 11; break;

                              case "PES": event.value = 12; break;

                              case "PF" : event.value = 13; break;

                              case "PDC": event.value = 14; break;

                              default: event.value = "14";

                              }

                           

                          })();