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

94

Likes

translate

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

Copy link to clipboard

Copied

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

Likes

translate

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.

Likes

translate

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

Copy link to clipboard

Copied

Nowhere any space?

Likes

translate

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?

Likes

translate

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

Copy link to clipboard

Copied

You can use "Donehoo Elementary" in the script.

Likes

translate

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
Adobe Community Professional ,
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;

Likes

translate

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

Copy link to clipboard

Copied

Why not?

Likes

translate

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.

Likes

translate

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

Copy link to clipboard

Copied

This should not be an issue.

Likes

translate

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