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

Change a Dropdown value displayed depending on a alert window response with Javascript

New Here ,
Apr 03, 2020 Apr 03, 2020

Hello World,

 

I am new to the world of Javascript and I don't know what I'm doing wrong in my code.

 

I am using a dropdown so the user can select one of 3 options: Yes, No or " ". When the user selects Yes or the "blank" option the code runs ok. But when the user select No I populated a pop-up alert (app.alert) asking if the user is really sure about their selection. If the user selects 'yes' in the pop-up alert, the code works; if the user selects 'no' in the pop-up alert the bold line in the code does not change the displayed value in the dropdown. It gets stuck with the No selection when I want it in "blank". It gets to hide the fields but doesn't change the dropdown.

 

I don't know what is the issue but besides that I am running the script in the Validation tab of the Dropdown box and the Commit selected value immediatly is checked.

________________________________________________

 

if (event.value == "Yes")
{
this.getField("Group1").value = "Choice1";
this.getField("Text1").display = display.hidden;
this.getField("Signature12").display = display.visible;
}

 

if (event.value == "No")
{

var Fail = app.alert("Are you sure you want to Fail this step?", 2, 2);

     if(Fail == 4) //User selected Yes in the pop-up
  {
     this.getField("Group1").value = "Choice2";
     this.getField("Text1").display = display.visible;
     this.getField("Signature12").display = display.hidden;
  }
     else if(Fail == 3) //User selected No in the pop-up HERE IS THE PROBLEM
  {
     this.getField("Group1").value = "Off";
     this.getField("Text1").display = display.hidden;
     this.getField("Signature12").display = display.hidden;
     this.getField("Dropdown1").value = " ";
  }
}

 

if (event.value == " ")
{
this.getField("Group1").value = "Off";
this.getField("Text1").display = display.hidden;
this.getField("Signature12").display = display.hidden;
}

TOPICS
How to , PDF forms
749
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 ,
Apr 03, 2020 Apr 03, 2020

Is Dropdown1 the field where you placed this code?

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
New Here ,
Apr 04, 2020 Apr 04, 2020

Yes, in the Validation Tab.

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 ,
Apr 04, 2020 Apr 04, 2020

Then change this:

this.getField("Dropdown1").value = " ";

To:

event.value = " ";

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
New Here ,
Apr 04, 2020 Apr 04, 2020
LATEST

That doesn't change the value in the Dropdown either 😕

It still have the No option displayed.

 

For some reason it doesn't change the value in the Dropdown box, but I have tried the same code using a Text field and it works fine.

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