function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Abi V 4Abi V 4 

How to set Inputtext field value to null on click of the button+lightning component

Hi,

I have the input text field where i want to clear the text value entered by user on click of the button.
Please suggest me how to achive this.It is really need ASAP.
Best Answer chosen by Abi V 4
sfdcMonkey.comsfdcMonkey.com
try this onces
setNotSoldvalues : function(component, event, helper) {
       
        var action = component.get("c.SaveNotSoldvalues"); 
        var compvalue = component.find("comp").get("v.value");    
         var compvalue1 = component.find("comp");
       action.setParams({ 
                  accId : component.get("v.AccountId"),
                     notsoldvalue1 : compvalue         
                            
               });
          
        action.setCallback(this, function(response) {
            var state = response.getState();        
                 
                if (state === "SUCCESS") 
                {  
                     
                    this.wrapperMultiValue(component);
                    //var emptyval=[];
                   component.set("v.notsoldvalue",null);
                } 
        });
         
        $A.enqueueAction(action);  
    }
Thanks
let me inform if it helps you

All Answers

sfdcMonkey.comsfdcMonkey.com
hi Abi
 can you share your component code and controller Please
Thanks
 
Abi V 4Abi V 4
setNotSoldvalues : function(component, event, helper) {
       
        var action = component.get("c.SaveNotSoldvalues"); 
        var compvalue = component.find("comp").get("v.value");    
         var compvalue1 = component.find("comp");
       action.setParams({ 
                  accId : component.get("v.AccountId"),
                     notsoldvalue1 : compvalue         
                            
               });
          
        action.setCallback(this, function(response) {
            var state = response.getState();        
                 
                if (state === "SUCCESS") 
                {  
                     
                    this.wrapperMultiValue(component);
                    //var emptyval=[];
                
                } 
        });
          //var compvalue1 = component.find("comp");    
          //alert(enter);
          //compvalue1.set('v.body', null); 
        $A.enqueueAction(action);  
    }


componenet

    <div>
              <fieldSet class="form-group col-md-2">
                             <div>
                            <legend class="slds-form-element__label"><b>Add Not Sold Products</b></legend>
                            <ui:inputText aura:id="comp"  class="form-control" value="{!v.notsoldvalue}"/>
//this value in need to make null on click of the Add button
                           </div>
             </fieldSet>  
        
        </div>
      <div>
              <div class="slds-modal__footer slds-modal__footer--directional">  
              <ui:button class="slds-button slds-button--neutral" label="Cancel" press="{!c.CancelNotSoldSection}"></ui:button>
              <ui:button class="slds-button slds-button--neutral" label="Add" press="{!c.setNotSoldvalues}"></ui:button>
              
              
              </div>
        
      </div>
sfdcMonkey.comsfdcMonkey.com
try this onces
setNotSoldvalues : function(component, event, helper) {
       
        var action = component.get("c.SaveNotSoldvalues"); 
        var compvalue = component.find("comp").get("v.value");    
         var compvalue1 = component.find("comp");
       action.setParams({ 
                  accId : component.get("v.AccountId"),
                     notsoldvalue1 : compvalue         
                            
               });
          
        action.setCallback(this, function(response) {
            var state = response.getState();        
                 
                if (state === "SUCCESS") 
                {  
                     
                    this.wrapperMultiValue(component);
                    //var emptyval=[];
                   component.set("v.notsoldvalue",null);
                } 
        });
         
        $A.enqueueAction(action);  
    }
Thanks
let me inform if it helps you
This was selected as the best answer
Abi V 4Abi V 4
Awesome Piyush,I didnt think to set the attribute value to null ,istead tried to set the body of the field.
Thanks a lot..You have saved my time a lot.