• if else drop down lists with calculations

# if else drop down lists with calculations

Community Beginner ,
Apr 08, 2022 Apr 08, 2022

Copied

I need some help.   On page 3 meals and lodging detail,  there is a drop down list that contains first, last, and all.  If user selects first, then the amount put into the Total GSA per diem rate is to be mulitplied by 75%, and the value put into the box next to it.   If the user selects all, then the full amount put into the Total GSA per diem rate is copied into the cell next to it.   If the user selects Last, then again the amount put into the Total GSA Per Diem Rate is multiplied by 75%.  If N/A is selected then 0.00 is put into the box next to it.   If have created the following  code:

var v = getField("DR1").valueAsString;
var g = getfield("GSA\$").valueAsString
// Set this field's value based on the input

if (v == "First") {
value = (g * .75);

} else if (v == "All") {
value = (g);

} else if (v == "Last") {
value = (g * .75);

} else {
value = ("0.00");

}
code editor does not see any error, Adobe acrobat pro accecpt it with no issue, what am i missing?
TOPICS
Comment review and collaborate PDF , Create PDFs , Edit and convert PDFs , JavaScript , PDF forms

Views

111

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
6 Replies 6
Apr 08, 2022 Apr 08, 2022

Copied

Replace value with event.value

Likes

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 Beginner ,
Apr 08, 2022 Apr 08, 2022

Copied

thanks for the reply, i tried replacing value with event.value, and still getting 0.00 for each one.

Likes

Report

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

Copied

You are using that script at wrong field, put it in field where you wan't to show result.

Make changes that Bernd suggested and also change:

this:

var g = getfield("GSA\$").valueAsString

to:

var g = Number(getField("GSA\$").valueAsString)

Likes

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 Beginner ,
Apr 08, 2022 Apr 08, 2022

Copied

I put the formula in the field when i wanted to show results, made the changes you suggested, and made the changes that Bernd suggested, but still gettting the same result.

Likes

Report

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

Copied

EDIT: there were also an error:

var g = Number(getfield("GSA\$").valueAsString)

should be:

var g = Number(getField("GSA\$").valueAsString)

Also in "DR1" and all dropdown fields in options tab check 'Commit selected value immediately'.

Likes

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 Beginner ,
Apr 08, 2022 Apr 08, 2022

Copied

LATEST

It worked!!!!!!! thank you so much.

Likes

Report

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