2 Replies Latest reply on Nov 10, 2010 8:43 AM by de1209

    Javascript help

    de1209

      Hi I am concatinating numerous fields in to one t

      show it one filed in the form as below(Steve has helped me on this).

       

      if

       

       

      (xfa.resolveNode("Page7.Q2a01_TX").rawValue.isNull) {

      str

      = str;

      }

      else

       

       

      {

      str

      = xfa.resolveNode("Page7.Q2a01_TX").rawValue;

      }

      if

       

       

      (xfa.resolveNode("Q2a02_TX").isNull) {

      str

      = str + "";

      }

      else

       

       

      {

      str

      = str + "\n" + xfa.resolveNode("Q2a02_TX").rawValue;

      }

      if

       

       

      (xfa.resolveNode("Q2a03_TX").isNull) {

      str

      = str + "";

      }

      else

       

       

      {

      str

      = str + "\n" + xfa.resolveNode("Q2a03_TX").rawValue; so on till 40 ...

       

      the RESULT now is   as

       

      Testing for question1

      Testing for question2

      Testing for question3

      Testing for question4

       

      but now i want to add "Q1" , "Q2" etc before by modifying as below which is understandbily not correct as

       

      if

       

       

       

      (xfa.resolveNode("Page7.Q2a01_TX").rawValue.isNull) {

      str

      = str;

      }

      else

       

       

       

      {

      str

       

      = "Q1" +  xfa.resolveNode("Page7.Q2a01_TX").rawValue;

      }

      if

       

       

       

      (xfa.resolveNode("Q2a02_TX").isNull) {

      str

      = str + "";

      }

      else

       

       

       

      {

      str

      = str + "\n" +"Q2"+ xfa.resolveNode("Q2a02_TX").rawValue;

      }

      if

       

       

       

      (xfa.resolveNode("Q2a03_TX").isNull) {

      str

      = str + "";

      }

      else

       

       

       

      {

      str

      = str + "\n" +"Q3"+  xfa.resolveNode("Q2a03_TX").rawValue; so on till 40 ...

       

      BUT THE RESULT NOW WOULD BE

      Q1 Testing for question1

      Q1 Q2 Testing for question2

      Q1 Q2 Q3 Testing for question3

      Q1 Q2 Q3 Q4 Testing for question4

       

      How can i just make the script to say

       

      Q1 Testing for question1

      Q2 Testing for question2

      Q3 Testing for question3

      Q4 Testing for question4

       

      I am a novice in JS ,  can somebody haelp me on this.

       

      Thanks In advance

      De1209

        • 1. Re: Javascript help
          Steve L Walker Level 5

          I cannot find the original form but is this the result you want?

           

          Untitled.png

           

          Where...

           

          // form1.page1.subform1.tf::calculate - (JavaScript, client)

           

          var str = "";

           

          if (form1.page1.subform1.nf1.isNull) {

            str = str;

          }

          else {

            str = "Q1 " + form1.page1.subform1.nf1.rawValue + "\n";

          }

           

          if (form1.page1.subform1.nf2.isNull) {

            str = str + "\n";

          }

          else {

            str = str + "Q2 " + form1.page1.subform1.nf2.rawValue + "\n";

          }

           

          if (form1.page1.subform1.nf3.isNull) {

            str = str + "\n";

          }

          else {

            str = str + "Q3 " + form1.page1.subform1.nf3.rawValue + "\n";

          }

           

          Steve

          • 2. Re: Javascript help
            de1209 Level 1

            Absolutely steve , You rock..