Expand my Community achievements bar.

SOLVED

Change dropdown value based on messageBox choice

Avatar

Level 1

Hi,

 

I have a Designer form where users are selecting the wrong choice from a dropdown.  My content provider requested to have a pop-up show the value selected, "Are you sure?", and Yes/No buttons. The dropdown's text color also changes based on the value selected.

 

I have everything working EXCEPT I can't change/clear the dropdown value when the user selects the pop-up No button.

I know the No choice is being passed along, as the dropdown's text color is changing, but I just can't get the value to change.

 

Code below - including things that didn't work in comments

 

crim.hearing.defStatus::change - (JavaScript, client)


//xfa.host.messageBox(xfa.event.newText + " and " + this.rawValue, "debug", 0,1);

//First, set colors - assume choice yes
if (xfa.event.newText == "RELEASED"){
this.font.fill.color.value = "0,128,0";
}else{
this.font.fill.color.value = "255,0,0";
}

 

//Second, show pop-up. Only NO (3) will work.
var txtMsg ="You have chosen "+ xfa.event.newText +". Are you sure? Select Yes or No.";
if(xfa.host.messageBox(txtMsg, "Confirm Value", 2, 2)=="3"){
//No selected. Set color to black and value to none
//this.rawValue=" ";
//xfa.event.newText=" ";
//xfa.event.newText="status";
//xfa.event.newText="select status";
this.rawValue=null;
//this.formattedValue=null;
//xfa.form.crim.hearing.defStatus.rawValue=null;
//xfa.form.crim.hearing.defStatus.formattedValue=null;
this.font.fill.color.value = "0,0,0";

//this.execEvent("change"); //just runs change event again


}else{
//Yes selected. Do nothing.
}

 

Any help appreciated!

1 Accepted Solution

Avatar

Correct answer by
Employee

@angelawatson you were quite close but the problem with your code at that event is: you are trying to overwrite the selection while it is still processing it. So even if you change, by the end of the change eevent it gets overwritten.

I tried a different event  (exit) for that second part and it seems to do what you want:

Kosta_Prokopiu1_0-1630915880082.png

Script in Exit:

this.font.fill.color.value = "0,0,0";
var txtMsg ="You have chosen "+ this.formattedValue +". Are you sure? Select Yes or No.";
if(xfa.host.messageBox(txtMsg, "Confirm Value", 2, 2) == "3"){
  this.rawValue=null;
}
if (this.rawValue != null) {
  if (this.formattedValue == "RELEASED"){
    this.font.fill.color.value = "0,128,0";
  } else {
    this.font.fill.color.value = "255,0,0";
 }
}

 

View solution in original post

2 Replies

Avatar

Correct answer by
Employee

@angelawatson you were quite close but the problem with your code at that event is: you are trying to overwrite the selection while it is still processing it. So even if you change, by the end of the change eevent it gets overwritten.

I tried a different event  (exit) for that second part and it seems to do what you want:

Kosta_Prokopiu1_0-1630915880082.png

Script in Exit:

this.font.fill.color.value = "0,0,0";
var txtMsg ="You have chosen "+ this.formattedValue +". Are you sure? Select Yes or No.";
if(xfa.host.messageBox(txtMsg, "Confirm Value", 2, 2) == "3"){
  this.rawValue=null;
}
if (this.rawValue != null) {
  if (this.formattedValue == "RELEASED"){
    this.font.fill.color.value = "0,128,0";
  } else {
    this.font.fill.color.value = "255,0,0";
 }
}