-2

i have created one submission form by using java script i need to reset the input data by using on reset button. Help me out of this.

reset: function() {
    var oInput1 = sap.ui.getCore().byId("firstname");
    oInput1.setValue("");*/
    this.getViewById("firstname").setValue("");*/
}

    input1.getId("firstname").setValue("");

onExit: function() {
    input1.setValue("");
}

the code is not resetting the form data

1 Answer 1

0

First of all your provided code-sample is incorrect, please correct it.

Second, onExit is executed when your view is destroyed, setting the input value to empty is rather useless there.

If you want to reset data of your input-field when clicking a button you'll need to have the following elements:

1) an Input- & Button-control (with press-event) in your XML-view.

2) an id assigned to your Input-control to be able to refer to the control when pressing the reset-button.

3) The press-event from the button worked out in your controller.

XML

<Input id="firstname" value=""/>
<Button text="Reset" press="reset"/>

Controller

reset: function() {
    var oInput1 = this.getView().byId("firstname");
    oInput1.setValue("");
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.