4 Replies Latest reply on Jan 22, 2012 1:08 AM by jck_drmjn

    for loop for text field

    jck_drmjn Level 1

      5 check boxes are A, B, C, D, E and 3 text fields are Text1, Text2,  Text3.

      If any check box is marked, corresponding value(A,B,C,D or E) will be goes into Text1, Text2 or Text3.

       

      It may be output like this

      Text1= A

      Text2= E

      Text3= C

       

      I have placed a code under checkbox A: mouc up:

       

      var aList = new Array("Text1.0","Text1.1","Text1.2");

       

      for(i = 0; i < aList.length; i++)

      {

      if(this.getField("CheckBox4").value = "1" && this.getField(aList[i]).value=="") {

      this.getField(aList[i]).value = "A";

      }

      }

       

      I do not get check mark when click on check box and "A" value is going into all text fields- Text1.0=A, Text1.1=A, Text1.2=A.

       

      What should I do?

        • 1. Re: for loop for text field
          George_Johnson MVP & Adobe Community Professional

          Which field is CheckBox4? Also, the line that includes this:

           

          this.getField("CheckBox4").value = "1"

           

          should be changed to read:

           

          this.getField("CheckBox4").value == "1"

           

          But whether that's really correct depends on your answer to the question.

          • 2. Re: for loop for text field
            jck_drmjn Level 1

            Thanks many .

             

            I have placed the code under on focus:

             

            var aList = new Array("Text1.0","Text1.1","Text1.2");

             

            for(i = 0; i < aList.length; i++)

            {

            if(this.getField("A").value = "1" && this.getField(aList[i]).value=="") {

            this.getField(aList[i]).value = "A";

            break;

            }

            }

             

            It is working fine but when uncheck I cannot remove A from text field. What should I do?

            • 3. Re: for loop for text field
              George_Johnson MVP & Adobe Community Professional

              As I indicated before, you need to change it to:

               

              this.getField("A").value == "1"

               

              Are you saying that this code is in the On Focus event of the checkbox named "A"?

              • 4. Re: for loop for text field
                jck_drmjn Level 1

                Yes A, B, C, D, E are check box. When I replace to this.getField("A").value == "1", it does not work. I have placed in the On Focus. I am not sure where is the perfect.

                 

                Actuall issue is that there are 5 checkbox name A, B, C,D,E. and 3 text field named Text1.0, Text1.1, Text1.2.

                 

                If user check A, textfield automatically filled with "A" (into any one text Field of three text Field)

                If user check C, textfield automatically filled with "C" (into any one text Field of three text Field)

                If user check D, textfield automatically filled with "D" (into any one text Field of three text Field)

                 

                So output may be like this:

                 

                Tex1.0= A

                Tex1.1= C

                Tex1.2= D

                 

                again if user uncheck A, corresponding value will be removed automatically. How can I do this?