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
diwakar rajputdiwakar rajput 

how can we get input value in a daynamic input field in lightning?

i am stuck on one problem. i have created dyamic field in lightning . now i want to get the input value? how can i get .

 
sfdcMonkey.comsfdcMonkey.com
hi can you please share your code
Thanks
GhanshyamChoudhariGhanshyamChoudhari
CMP
<aura:component implements="force:appHostable" >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    {!v.body}
</aura:component>

Controller
({
    doInit : function(cmp) {
        var val = 'sometext';
        // val will be add dynamically here
        $A.createComponent(
            "lightning:input",
            {                
                "name":"Name",
                "label":"myname",
                "value":val                
            },
            function(inputtxt, status, errorMessage){                
                if (status === "SUCCESS") {
                    var body = cmp.get("v.body");
                    body.push(inputtxt);
                    cmp.set("v.body", body);
                }
                else if (status === "INCOMPLETE") {
                    console.log("No response from server or client is offline.")
                    
                }
                    else if (status === "ERROR") {
                        console.log("Error: " + errorMessage);                        
                    }
            }
        );
        
    },    
    
})

 
santhosh shivalingappasanthosh shivalingappa
Hi, 

When I tested your code, I don't see any in that. The value ''sometext'' is getting populated in the input text box. Please let us know if the issue is other.