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

script check

Participant ,
Mar 26, 2019 Mar 26, 2019

Copy link to clipboard

Copied

I have been using this script below to select Yes or No to populate text fields. It also works in other ways as well. Well, now I would like to include a tax field using the same script but what it's doing is, it's adding the "1", "2" or "3" inside of the tax rate field. See the script to better understand.

Script:

if (event.value.toUpperCase()=="1") event.value = ".08";

if (event.value.toUpperCase()=="2") event.value = ".095";

if (event.value.toUpperCase()=="3") event.value = ".10";

What can I do or modify to have the value be entered into the tax rate field as the tax not the "1", "2" or "3"? It's probably very simple but it's beyond me. Can someone please help me out? Thanks.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

529

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Mar 26, 2019 Mar 26, 2019

Use it as a custom calculation or validation script, instead.

Votes

Translate

Translate
Community Expert ,
Mar 26, 2019 Mar 26, 2019

Copy link to clipboard

Copied

So you want the user to be able to enter "1" and have it automatically convert to ".08", for example?

If so, your code should work (although you don't need the toUpperCase() part...). Where did you place it?

Votes

Translate

Translate

Report

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
Participant ,
Mar 26, 2019 Mar 26, 2019

Copy link to clipboard

Copied

Heya Gilad,

I placed the script in the Custom Format. Although, I've tried it in some other places too. You are correct, it does work. It shows the tax rate decimal but it multiplies the "1", "2" or "3" by the Total. Not the tax rate (ex. .0975 etc). I'm a bit confused and don't know what to try.

Votes

Translate

Translate

Report

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
Community Expert ,
Mar 26, 2019 Mar 26, 2019

Copy link to clipboard

Copied

Use it as a custom calculation or validation script, instead.

Votes

Translate

Translate

Report

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
Participant ,
Mar 26, 2019 Mar 26, 2019

Copy link to clipboard

Copied

Yes, I tried that. But, the number value is what gets calculated. It multiplies the Total field by "1" or by "2". No matter where I place the script. The tax amount doesn't get included in the calculation. The tax amount will show as selected, but it doesn't calculate that amount. When I click on the tax rate field to clear the field I see there's a number 1 or 2 (if that was selected) in the tax rate field.

Can I use a script to push the tax amount to a second text field? Then calculate it from that field? This is beyond me.

Votes

Translate

Translate

Report

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
Community Expert ,
Mar 26, 2019 Mar 26, 2019

Copy link to clipboard

Copied

That will happen if you use the Format event, as it doesn't change the actual value of the field, but not if you use validation or calculation, which do change it.

Votes

Translate

Translate

Report

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
Participant ,
Mar 26, 2019 Mar 26, 2019

Copy link to clipboard

Copied

I retried it in the Validation. I placed it before any other script that was in there and it worked. Does having the script at the top of the scripts have anything to do with how the script, or if the script will perform? I tried it in the Validation and tried it in the Custom Calc and it did not work. I would hate to think that I would do something wrong or not correct. Hmmm. Thanks, Gilad.

Votes

Translate

Translate

Report

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
Community Expert ,
Mar 26, 2019 Mar 26, 2019

Copy link to clipboard

Copied

LATEST

That depends on what the rest of the code does...

Votes

Translate

Translate

Report

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