Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


If/else doesn't seem to be working

Participant ,
Jun 24, 2021 Jun 24, 2021

Copy link to clipboard

Copied

Code off 2 is a dropdown box and depending on what someone chooses, I want a specific sentence to appear in a text box further down the document.

Currently, if I choose any of the 5% discount numbers, this seems to be ok, but if I pick any of the 10% discount numbers, it doesn't show me the 10% discount sentence. Don't know what I've missed, so any help would be appreicated.

 

var selectedProducts = this.getField("Code off 2").value;
if (selectedProducts=="...") event.value = " ";
else if (selectedProducts=="A21305", "A40005", "A50005", "A55005", "A80005", "A90105", "A90205", "A92005", "A99005") event.value = "Remise de 5% sur tarif en vigueur des encres et étiquettes";
else if (selectedProducts=="A21310", "A40010", "A50010", "A55010", "A80010", "A90110", "A90210", "A92010", "A99010") event.value = "Remise de 10% sur tarif en vigueur des encres et étiquettes";

else event.value = " ";

 

 

TOPICS
JavaScript, PDF forms

Views

203

Likes

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

correct answers 1 Correct answer

Adobe Community Professional , Jun 24, 2021 Jun 24, 2021
This is not valid JS code: if (selectedProducts=="A21305", "A40005", "A50005", "A55005", "A80005", "A90105", "A90205", "A92005", "A99005") You need to use either something like this: if (selectedProducts=="A21305" || selectedProducts=="A40005" || selectedProducts=="A50005" ... Or: if (["A21305", "A40005", "A50005", "A55005", "A80005", "A90105", "A90205", "A92005", "A99005"].indexOf(selectedProducts)!=-1) ...

Likes

Translate

Translate
Adobe Community Professional ,
Jun 24, 2021 Jun 24, 2021

Copy link to clipboard

Copied

This is not valid JS code:

if (selectedProducts=="A21305", "A40005", "A50005", "A55005", "A80005", "A90105", "A90205", "A92005", "A99005")

You need to use either something like this:

if (selectedProducts=="A21305" || selectedProducts=="A40005" || selectedProducts=="A50005" ...

Or:

if (["A21305", "A40005", "A50005", "A55005", "A80005", "A90105", "A90205", "A92005", "A99005"].indexOf(selectedProducts)!=-1) ...

Likes

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
Participant ,
Jun 24, 2021 Jun 24, 2021

Copy link to clipboard

Copied

LATEST

Thank you so much!

Likes

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