Javascript for form

Jan 05, 2018

Copy link to clipboard

Copied

Would someone be able to help me write a java script for the following:

I have a form that has two columns:

1st column is Meals

where they input the $ Amount

2nd column is a dropdown menu where they select one of the following.

B -  has a maximum of $10.00

L - has a maximum of $15.00

D - has a maximum of $25.00

What I would like the script to do…if possible.

Under the 1st Column when they fill in the $ amount and then select from the dropdown menu (B, L or D) if the dollar amount exceeds the maximum it will automatically change the amount in the 1st column (Meals $ Amount) to the maximum amount.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

57

Likes

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

Javascript for form

Jan 05, 2018

Copy link to clipboard

Copied

Would someone be able to help me write a java script for the following:

I have a form that has two columns:

1st column is Meals

where they input the $ Amount

2nd column is a dropdown menu where they select one of the following.

B -  has a maximum of $10.00

L - has a maximum of $15.00

D - has a maximum of $25.00

What I would like the script to do…if possible.

Under the 1st Column when they fill in the $ amount and then select from the dropdown menu (B, L or D) if the dollar amount exceeds the maximum it will automatically change the amount in the 1st column (Meals $ Amount) to the maximum amount.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

58

Likes

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
Jan 05, 2018 0
Jan 05, 2018

Copy link to clipboard

Copied

To do this you'll need to change the export value on the dropdown items to match the dollar amounts. so for the first one the export value would be 10.

Then in the "Format" tab on the Field Properties, Select "Custom" formatting, and then add this code to the KeyStroke script.

if(!event.willCommit)

{

     if(this.getField("Test").value > event.changeEx)

           this.getField("Test").value = event.changeEx;

}

There is a couple of issues with this code.

1. It only handles the case where the user selects from the dropdown. It does not prevent the user from changing the value at a later time.

2. You'll need to enter this code into every dropdown in the column. This is not only tedius, it is error prone. Especially if you have to make changes, which you will. A better strategy is to create this code as a document level function, then call it from the field event.

Likes

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
Reply
Loading...
Jan 05, 2018 1