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

Custom calculation script for if / else if

Community Beginner ,
Feb 10, 2021 Feb 10, 2021

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
1.2K
Translate
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

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

Translate
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

Yes. I even checked the spelling.

Translate
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

Nowhere any space?

Translate
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
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?
Translate
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

You can use "Donehoo Elementary" in the script.

Translate
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

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

 

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


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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

Why not?

Translate
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

You are awesome! It worked. Thank you so much.

Translate
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
LATEST

This should not be an issue.

Translate
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