4 Replies Latest reply on Oct 6, 2011 1:31 PM by vasheck1

    Drop-down to populate textfield

    vasheck1

      Hi,

       

      I think this should be pretty simple to do... but I can't figure out how to get values of my textfields to change based on the drop-down selection.

       

      Here's an example what I am trying to do...

      I have one drop-down (combo-box) and two textfields

       

      [drop-down] - DropDownList1

      - Item: Mon

      - Export Value: Mon

      - Item: Tue

      - Export Value: Tue

      - Item: Wed

      - Export Value: Wed

       

      [textfield] - TextField1

      [textfield] - TextField2

       

      Now, I would like the TextField1 to display "Tue" if "Mon" is selected in the drop-down and

      TextField2 to display "Wed" if "Mon" is selected...

      I can't figure out what I am doing wrong.

       

      I have this javascript under the "Actions" tab (of the ComboBox)

       

      Actions

      - Mouse Exit (Select Trigger)

      - Run a Javasript (Selection Action)

       

       

      switch(DropDownList1.rawValue){

       

      case "Mon":

      TextField1.rawValue = "Tue";

      TextField2.rawValue = "Wed";

      break;

      case "Tue":

      TextField1.rawValue = "Wed";

      TextField2.rawValue = "Thu";

      break;

      case "Wed":

      TextField1.rawValue = "Thu";

      TextField2.rawValue = "Fri";

      break;

      }

        • 1. Re: Drop-down to populate textfield
          BarlaeDC Level 4

          Hi,

           

          Can you clarify: Are you creating an AcroForm (form created in Acrobat) or A LiveCycle form ( form created in LiveCycle Designer)?

           

          Regards

           

          Malcolm

          • 2. Re: Drop-down to populate textfield
            vasheck1 Level 1

            Hi Malcolm,

             

            It's an Acrobat Form... I am using Acrobat 6.

             

            I got it working... most likely not the proper way... but it's working now...

             

            This is what I put in the ComboBox... to validate

            if(event.value == "Mon")

            {

                day1 = "Tue";

                day2 = "Wed";

            }

            else if(event.value == "Tue")

            {

                day1 = "Wed";

                day2 = "Thu";

            }

             

            And this is what I put in the "textfield" to "calculate"

            event.value = day1; (textfield 1)

            event.value = day2; (textfield 2)

            etc...

             

            I imagine it's an ackward and lenghtly way of doing but I am not familiar with Acrobat Actionscript.

            If you could show me a better way of doing it, it would be greatly appreciated.

             

            Thank you!

            • 3. Re: Drop-down to populate textfield
              BarlaeDC Level 4

              Hi,

               

              Your code is a little awkward as it is calling more code that is necessary in terms of the extra calculate event. If you changed your code to this you could probably do it all in the comboBox code

               

              var text1 =   this.getField("TextField1");

              var text2 = this.getField("TextField2");

              if(event.value == "Mon")

              {

                   text1.value  = "Tue";

                   text2.value = "Wed";

              }

              else if(event.value == "Tue")

              {

                   text1.value= "Wed";

                   text2.value= "Thu";

              }

               

              but as I said this is just a optimisation that could be made as it would keep all the code in the one place making it  a little easier to maintain.

               

              Regards

               

              Malcolm

              • 4. Re: Drop-down to populate textfield
                vasheck1 Level 1

                Hi Malcolm,

                 

                I just learnt something new today!

                It works like a charm.

                 

                Thank you very much. Your help is greatly appreciated.

                 

                Vasek