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.
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.