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
d.tejdeep@nicomatic.ind.tejdeep@nicomatic.in 

pass html input data to lightning js controller

<input type="text" id="getet"/>
var nameField =component.find("getet");
        var itemname = nameField.get("v.value");

        alert(itemname);

I want to pass HTML input data  to the lighting controller 
Meenu MathewMeenu Mathew
Hi,

Kindly use JQuery 
var nameField =$("#getet").val();

Thanks
Sagar Wahal 1Sagar Wahal 1
I would suggest using the lightning input tags to implement this. For example if you want to create an input text box you can do something like this:
<aura:attribute name="firstName" type="String"/>
<lightning:input name="input8" value="{! v.firstName }" placeholder="type your first name..." label="Text field with attribute binding" />
Here we have first created an lightning attribute of type string. This attribute has been bounded to the lightning input field. Whatever value is entered in this text box will be updated to the 'firstName' attribute. To access this value you can simply write something like this:
var firstNameVal = component.get("v.firstName");
To find a list of different types of lightning input attributes and more information on the lightning design system Click Here (https://developer.salesforce.com/docs/component-library/bundle/lightning:input/example#lightningcomponentdemo:exampleInputText).

In-case your requirement is not fulfilled by the lightning input tags (which is unlikely), I would recommend using the 'aura:id' rather than the native 'id' attribute.
Meenu MathewMeenu Mathew
Hi,

If using JQuery you may need to upload the script as static resource and use it in your component.
Another method is to use simple javascript to acces the input data.
 
var inputdata = document.getElementById("getet");
alert('InputData --->'+inputdata );

Or you may use lightning input tags as Sagar mentioned.

Thanks