Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to I make a text value in one field equal a number in another field.

New Here ,
Feb 16, 2018 Feb 16, 2018

Hi,

I have minimal java script experience (go easy on me please) but this is what I’m trying to achieve

For example...

If I type the letters ”DT” in form field “aa” I want the value of “10” to appear in form field “bb“

I have trawled the forum and can’t find any solution. Can anyone provide a simple script for this please?

I have 4 different text values for field “aa” which are “DT”, “EI”, “NI” and “VI” and I want each of these text values to equal a different number in form field “bb“

Any help appreciated, thanks in advance.

Dave

TOPICS
PDF forms
2.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
LEGEND ,
Feb 16, 2018 Feb 16, 2018

If you set the export value of each dropdown item equal to what the value of the bb field should be when the item is selected, you can use the following custom Keystroke script for the dropdown. You do this by selecting a custom Format on the Format tab of the Field Properties dialog. It assumes that the dropdown has a blank item that is really just a single space with no export value.

// Custom Keystroke script for dropdown

if (!event.willCommit) {

    getField("bb").value = event.changeEx === " " ? "" : event.changeEx;

}

You should also select the "Commit selected value immediately" checkbox on the Options tab of the dropdown field properties dialog. If you want to use something other than a single blank to indicate a value has not been selected, just replace the single space string (" ") in the code above with whatever string you want to use.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 16, 2018 Feb 16, 2018

What should happen if something other than those four "aa" values that you listed are entered, and what should happen if "aa" is blank? If you want the user only enter those four values, consider using a dropdown instead of a text field.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 16, 2018 Feb 16, 2018

Hi George,

Yes I will be using a dropdown.

But can you also configure it so that if no value is entered it just leaves a blank in “bb“

Dave

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 16, 2018 Feb 16, 2018

If you set the export value of each dropdown item equal to what the value of the bb field should be when the item is selected, you can use the following custom Keystroke script for the dropdown. You do this by selecting a custom Format on the Format tab of the Field Properties dialog. It assumes that the dropdown has a blank item that is really just a single space with no export value.

// Custom Keystroke script for dropdown

if (!event.willCommit) {

    getField("bb").value = event.changeEx === " " ? "" : event.changeEx;

}

You should also select the "Commit selected value immediately" checkbox on the Options tab of the dropdown field properties dialog. If you want to use something other than a single blank to indicate a value has not been selected, just replace the single space string (" ") in the code above with whatever string you want to use.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 16, 2018 Feb 16, 2018

Thanks for that George, appreciate you taking the time to help. Will give this a go today and let you know the outcome.

Dave

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 17, 2018 Feb 17, 2018
LATEST

George,

That works perfectly! Exactly what I was looking for!

Thanks again! Appreciate it!

Dave

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines