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

Custom calculation script for if / else if

Community Beginner ,
Feb 10, 2021 Feb 10, 2021

Copy link to clipboard

Copied

I have a dropdown box "SHIP" that I have different locations listed. I'm trying to fill in the street address a text field box based on the selection made from the dropdown box. I am VERY new to all of this and am needing guidance from the experts. With the below script I can only get the first selection to appear which is ADAMS. When I select the second choice, DONEHOO, it does not work.

 

var SHIP=this.getField("SHIP").value;

if (SHIP=="ADAMS") {
event.value="address 1";
} else if (SHIP=="DONEHOO") {
event.value="address 2";
} else event.value="";

TOPICS
JavaScript , PDF forms

Views

783

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 ,
Feb 10, 2021 Feb 10, 2021

Copy link to clipboard

Copied

In the dropdown list does you use the exact the word "DONEHOO"  ? 

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 ,
Feb 10, 2021 Feb 10, 2021

Copy link to clipboard

Copied

Yes. I even checked the spelling.

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 ,
Feb 10, 2021 Feb 10, 2021

Copy link to clipboard

Copied

Nowhere any space?

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 ,
Feb 10, 2021 Feb 10, 2021

Copy link to clipboard

Copied

OK I did have a space. I changed it and it worked. I had Donehoo Elementary
in the list and script but I was just trying to shorten it. What do I need
to do if I do have multiple words and need a space?

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 ,
Feb 10, 2021 Feb 10, 2021

Copy link to clipboard

Copied

You can use "Donehoo Elementary" in the script.

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 ,
Feb 10, 2021 Feb 10, 2021

Copy link to clipboard

Copied

You should not use the same name for the variable and for the field.

 

var SHIP=this.getField("SHIP").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 Expert ,
Feb 10, 2021 Feb 10, 2021

Copy link to clipboard

Copied

Why not?

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 ,
Feb 10, 2021 Feb 10, 2021

Copy link to clipboard

Copied

You are awesome! 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
Community Expert ,
Feb 10, 2021 Feb 10, 2021

Copy link to clipboard

Copied

LATEST

This should not be an issue.

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