javascript - Enable/Disable form elements and changing the values of button at a time? -
requirement: text is a button with "disabled" when the page opens, then I want to disable it when the user clicks on button , I want to enable my form field and at the same time I want to change the value of my button to "enabled."
I have an example of how the button's value, but how can I enable / disable it at the same time?
& lt; H: form & gt; Please press this button & lt; H: command button id = "cb1" value = "# {ActionBean.buttonText}" instant = "true" functionalist = "# {ActionBean.processMyAction}" /> & Lt; / H: form & gt;
My Bean class looks like this:
/ * action listener method * / public zeroes process my action (verb phenomenon) {disable =! Disable; System.out.println ("disable:" + disabled); If (buttonText.equals ("disable")) {buttonText = "enable"; System.out.println ("Button Type:" + Button); } Else {buttonText = "disable"; System.out.println ("Button Type:" + Button); }
This is an example for you to try.
& lt; H: body & gt; & Lt; H: form & gt; & Lt; H: InputTest disabled = "# {myBean.disabled}" & gt; & Lt; / H: InputText & gt; & Lt; H: command button value = "# {myBean.buttonName}" action listener = "# {myBean.changeButton}" & gt; & Lt; / H: Command button & gt; & Lt; / H: form & gt; & Lt; / H: Body & gt;
and bean,
public class MyBean {public MyBean () {this.disabled = true; This.buttonName = "edit"; } Public string getButtonName () {return buttonName; } Public Zero Set Bootnames (String Button Name) {this.buttonName = buttonName; } Private string button name; Public Zero Turn Button (Action Event Event) {If (this.buttonName.equals ("edit")) {this.disabled = false; This.buttonName = "save"; } Else {this.disabled = true; This.buttonName = "edit"; }} Public boolean is disabled () {return disabled; } Public Zero Set Disable (Boolean Disabled) {this.disabled = disabled; } Private boolean disabled; }
Comments
Post a Comment