Expand my Community achievements bar.

Resetting drop down value

Avatar

Former Community Member

I have a dropdown and based on the option selected, a bunch of thing happen. In order to prevent accidental change, I need to display a warning message to ask the user to confirm the change. If the user confirms, the drop down option is changed. If he declines, the drop down need to revert to previous value.

I am not being able to revert back to the previous value. Here's my script (firing on "change" event).

var previousText = xfa.event.prevText;

var currentText = xfa.event.newText;

//app.alert("previousText: " + previousText  +" , new: " + currentText  );

if(previousText  != currentText ) {

   var answer = xfa.host.messageBox("Do you really want to change the value?", "Attention", 2,1);

   //app.alert(answer);

   if (answer == 1) { // 1 is OK, 2 is Cancel

    DoSomething();

   }

   if (answer == 2) {

    this.rawValue = previousText;

   }

}

 

 

4 Replies

Avatar

Former Community Member

"If the user confirms, the drop down option is changed." What is it changed too?

Steve

Avatar

Former Community Member

Say there are two values in the drop down. Yes and No. Suppose the current value selected is "Yes". Now the user selects "No". I need to warn him that this might cause some data to delete/change. If the user confirms to make the change (by clicking OK on the messagebox) I proceed as intended. (Upto here, there's no problem)

But if the user declines to proceed (by clicking 'Cancel' on the messagebox). I wouldn't go ahead with the changes (this is not a problem as well).

I also need to revert the drop down value to "Yes" (i.e. stop the drop down value to become "No"). I am not being able to do it.

Avatar

Former Community Member

I am not sure I follow completely. Take a look at the attached for my interpretation.

Steve

Avatar

Former Community Member

Thank you for the form Steve. So here's how it works (in terms of the form - I'm not considering the zip-code dropdown).

1) The "Change" dropdown is a required filed. It will always have either Yes or No.

When you click on the "Change" dropdown, and change the current value (Yes to No or No to Yes). You are prompted (messagebox): "Do you really want to do it?"

If you select "Yes" on the messagebox, say the city values change.

If you select "No" or "Cancel" the city values don't change. Also, the value in the "Change" dropdown reverts to what it was (if you were changing the value from Yes to No, it remains Yes and vice-versa.)