Expand my Community achievements bar.

SOLVED

How do I change the "Enabled" state of a button when a user changes data in a field in a form?

Avatar

Level 2

On my form page, I have 3 buttons labeled:  Commit, Undo,  Done   respectively.  When the form first opens, popuplated with data, the Commit and Undo buttons are disabled (designed that way in Desing mode).  When the user changes any data in any field, I would like the "Done" button to become disabled, and the Commit and Undo buttons to become enabled.   How do I "tell" the Commit and Undo buttons to become enabled on data change?


After the data is committed to the database, how do I tell the Commit and Undo buttons to become disabled and the "Done" button to become enabled again?

Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Level 1

Create a bindable boolean variable in the form page say [Bindable]private var formChanged:Boolean = false;

set this to true in the change events of any of the form input fields.

Buttons enabled state can be bound to this boolean property like this

<mx:Button id="btnCommit" enabled="{formChanged}"/>

<mx:Button id="btnUndo" enabled="{formChanged}"/>

<mx:Button id="btnDone" enabled="{!formChanged}"/>

After the data is committed to the database, set the formChanged to false

View solution in original post

1 Reply

Avatar

Correct answer by
Level 1

Create a bindable boolean variable in the form page say [Bindable]private var formChanged:Boolean = false;

set this to true in the change events of any of the form input fields.

Buttons enabled state can be bound to this boolean property like this

<mx:Button id="btnCommit" enabled="{formChanged}"/>

<mx:Button id="btnUndo" enabled="{formChanged}"/>

<mx:Button id="btnDone" enabled="{!formChanged}"/>

After the data is committed to the database, set the formChanged to false