Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Change dropdown value based on messageBox choice

angelawatson
Level 1
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
Kosta_Prokopiu1
Correct answer by
Employee
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
Kosta_Prokopiu1
Correct answer by
Employee
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