1 Reply Latest reply on May 22, 2013 4:34 PM by George_Johnson

    combo box fills text else make text editable

    ntrevino_ba

      I have a combo box with different states. If one of 3 states are selected in the combo box the text field is automatically filled but if it is one of the other states, i'd like for the user to be able to enter text in that same field. I assigned values 1,2,and 3 to each of the states that have predetermined information.

       

      Currently I have the following script which works well when one of the 3 states are selected but doesn't permit editing the text field if it is another state:

       

      var nState = this.getField("Property St");

       

       

      if(nState.value == 1) {

      event.value = "State1 \n try 2nd line \n line 3";

      event.target.readonly = true;

      }

      else if (nTitle.value == 2) {

         event.value = "State2 \n try 2nd line \n line 3";

         event.target.readonly = true;

      }

      else if (nTitle.value == 3) {

         event.value = "State3\n try 2nd line \n line 3";

         event.target.readonly = true;

      }

      else {

         event.value = "";

         event.target.readonly = false;

      }

       

       

       

      I'd appreciate any help on this.

        • 1. Re: combo box fills text else make text editable
          George_Johnson MVP & Adobe Community Professional

          Instead of using a custom calculation script for the text field, I would suggest using something like the following as the combo box's custom Keystroke script and make sure that the "Commit selected value immediately" option is selected:

           

          // Custom Keystroke script for combo box

          (function () {

           

             if (event.willCommit) {

                return;

             }

           

             // Get the export value of the selected state

             var nState = event.changeEx;

           

             // Get a reference to the text field

             var f = getField("Text1");

           

             if (nState == 1) {

           

                f.value = "State 1 \rtry 2nd line \rline 3";

                f.readonly = true;

           

             }

           

             else if (nState == 2) {

           

                f.value = "State 2 \rtry 2nd line \rline 3";

                f.readonly = true;

           

             }

           

             else if (nState == 3) {

           

                f.value = "State 3 \rtry 2nd line \rline 3";

                f.readonly = true;

           

             }

           

             else {

           

                f.value = "";

                f.readonly = false;

           

             }

           

          })();

           

           

          Change "Text1" to the actual name of the text field.