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

if else drop down lists with calculations

Community Beginner ,
Apr 08, 2022 Apr 08, 2022

Copy link to clipboard

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
Create PDFs , Edit and convert PDFs , JavaScript , PDF forms

Views

687

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

Copy link to clipboard

Copied

Replace value with event.value

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

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)

 

 

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

Copy link to clipboard

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.   

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

Copy link to clipboard

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

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

Copy link to clipboard

Copied

LATEST

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

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