Change a Dropdown value displayed depending on a alert window response with Javascript
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;
}