Index matching with form  SOLVED

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Paul - Tracker Supp, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software

Post Reply
Ocasio
User
Posts: 10
Joined: Thu Oct 17, 2019 3:06 pm

Index matching with form

Post by Ocasio » Thu Mar 05, 2020 6:42 pm

Hello, I am trying to make a field value change based on another field value

var PP = this.getField("Primary Person").value
if( PP = "Person 2" ) event.value = "010101";
else if( PP = "Person 5" ) event.value = "058916";

In this case, I want "010101" to be automatically fill in the field value if the field "Primary Person" is filled with "Person 2", which has a dropdown menu of 5 persons.

User avatar
TrackerSupp-Daniel
Site Admin
Posts: 3420
Joined: Wed Jan 03, 2018 6:52 pm

Re: Index matching with form

Post by TrackerSupp-Daniel » Fri Mar 06, 2020 11:11 pm

Hi, Ocasio

Dropdown fields are a type of combobox, as such you will likely need to use the "getItemAt" method to identify which item is being selected and denote special handling for each item. Please find more details in the Adobe JS API reference, on page 456:
https://www.adobe.com/content/dam/acom/ ... f#page=456

Kind regards,
Daniel McIntyre
Support Technician
Tracker Software Products (Canada) LTD

Support: <Support@tracker-software.com>
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623

Ocasio
User
Posts: 10
Joined: Thu Oct 17, 2019 3:06 pm

Re: Index matching with form

Post by Ocasio » Sat Mar 07, 2020 1:17 am

I did try the code on a text field rather than a dropdown box, still not getting the expected results. Could you tell me if the code is wrong?

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 14020
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Index matching with form

Post by Tracker Supp-Stefan » Mon Mar 09, 2020 12:28 pm

Hello Ocasio,

Please take a look at the attached sample on how you can make this work:
Drop_down_JS_test.pdf
(5.25 KiB) Downloaded 42 times

Kind regards,
Stefan

Ocasio
User
Posts: 10
Joined: Thu Oct 17, 2019 3:06 pm

Re: Index matching with form

Post by Ocasio » Mon Mar 09, 2020 1:15 pm

Thank you, is very close but not quite what i am looking for

For example, if Dropdown is "Option 1" then Text 2 is "00155"

Its a match table, none of the characters in one field are repeated in the other field

User name | User ID
Maria = 00155
Ralph = 87449
Etc...

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 14020
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Index matching with form  SOLVED

Post by Tracker Supp-Stefan » Mon Mar 09, 2020 1:31 pm

Hello Ocasio,

Certainly - here's the modified script showing you how you can push an arbitrary value for the text field (I've only covered the "first" option, and the others I left as they were - to keep my sample showing both options. You can obviously just make checks for each of the values in the drop down, and push the desired value in the text field from it:
Drop_down_JS_test_modified.pdf
(5.27 KiB) Downloaded 7 times

Kind regards,
Stefan

Ocasio
User
Posts: 10
Joined: Thu Oct 17, 2019 3:06 pm

Re: Index matching with form

Post by Ocasio » Mon Mar 09, 2020 2:30 pm

Thank you, I modified and it works fine like this.

Code: Select all

if (event.willCommit)
{
if (event.value == "Option 1"){
	this.getField("Text1").value = "01";
	}
	else if (event.value == "Option 2"){
    this.getField("Text1").value = "02";
    }
    else if (event.value == "Option 3"){
      this.getField("Text1").value = "03";
      }
      else if (event.value == "Option 4"){
        this.getField("Text1").value = "04";
        }
        else if (event.value == "Option 5"){
          this.getField("Text1").value = "05";
          }
          else if (event.value == "Option 6"){
            this.getField("Text1").value = "06";
            }
            else if (event.value == "Option 7"){
              this.getField("Text1").value = "07";
              }
              else if (event.value == "Option 8"){
                this.getField("Text1").value = "08";
                }
                else if (event.value == "Option 9"){
                  this.getField("Text1").value = "09";
                  }
                  else if (event.value == "Option 10"){
                    this.getField("Text1").value = "10";
                    }
}

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 14020
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Index matching with form

Post by Tracker Supp-Stefan » Mon Mar 09, 2020 3:18 pm

Hello Ocasio,

Glad I could help!

Kind regards,
Stefan

Post Reply