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

If/else doesn't seem to be working

Contributor ,
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

470

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

Community Expert , 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) ...

Votes

Translate

Translate
Community Expert ,
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) ...

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

Copy link to clipboard

Copied

LATEST

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