4 Replies Latest reply on May 22, 2015 2:15 AM by martins82060393

    get.Field from 2 different text fields

    martins82060393

      Hi,

       

      I have this script i'm trying to run.

       

      The purpose of the script is to get csv info from a text field.

      Now the text field is maxed out character wise, so i've created a new text field (KnownInstruments2).

       

       

      How do i make the script below to search in both: "KnownInstruments & KnownInstruments2? Anyone who can provide a quick answers, would be so much appreaciated

       

       

      function LookupInstrument()

      {

        var ins=this.getField('Instrument').value;

        var knowninstruments=this.getField('KnownInstruments').value + ";" + this.getField(KnownInstruments2).value;

        var lines=knowninstruments.split('\r');

       

      Thanks!

        • 1. Re: get.Field from 2 different text fields
          try67 MVP & Adobe Community Professional

          Your description of what you want to achieve is not very clear... So you want to search for one string inside another, and then what?

          • 2. Re: get.Field from 2 different text fields
            martins82060393 Level 1

            tI will start search in "KnownInstruments" - but the text field can't have any more characters in it's "default values".
            Then i made one more text field called it "KnownInstruments2".

             

            I have a field, and if i trype: 671 - then it will find instrument 671 and it customers. But if it's not in "knowninstruments" i will go to KnownInstruments2 and search.

            Here is the whole script;

             

             

            function LookupInstrument()

            {

              var ins=this.getField('Instrument').value;

              var knowninstruments=this.getField('KnownInstruments').value;

              var lines=knowninstruments.split('\r');

             

             

              this.getField('Firm').value='';

              this.getField('ContactPerson1').value='';

              this.getField('Email1').value='';

              this.getField('Distributor1').value='';

              this.getField('DistributorEmail1').value='';

             

             

              for (var i=0; i<lines.length; i++) {

                var line=lines[i];

                var columns=line.split(';');

             

             

                // Check if found instrument.

                if (columns[0] == ins) {

                   this.getField('Firm').value=columns[1];

                   this.getField('ContactPerson1').value=columns[2];

                   this.getField('Email1').value=columns[3];

                   this.getField('Distributor1').value=columns[4];

                   this.getField('DistributorEmail1').value=columns[5];

                   break;

                }

              }

            }

            • 3. Re: get.Field from 2 different text fields
              try67 MVP & Adobe Community Professional

              So you just want to know how to combine the values of two fields into a single string? You were on the right path, the only problem is you didn't put the second field name in quotes... So use this:

               

              var knowninstruments = this.getField("KnownInstruments").valueAsString + ";" + this.getField("KnownInstruments2").valueAsString;

              • 4. Re: get.Field from 2 different text fields
                martins82060393 Level 1

                Thanks a lot tyr67! Worked like a charm!