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
Mike O.Mike O. 

Read value from component in controller.js

I have the following in the component:
<lightning:input type="number" aura:id="input1" name="input1" value="1" required="true" />
In the controller.js I have an action that returns a value from the component controller.

I'd like to multiply this value with the number entered in "input1" and display it.

I do not seem able to read the value that is in "input1". I tried
alert('cmp.find(input1) = ', cmp.find('input1').get('v.value'));
and it shows an empty value.

thank you
 
Best Answer chosen by Mike O.
Amit Singh RathaurAmit Singh Rathaur
Hi Mike,

Use '+' in your alert, you are using ' ,' in alert

Use below code of snippet in your code and your alert will be shown the value

alert('cmp.find(input1) = '+ c.find('input1').get('v.value'));

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,

Amit Singh Rathaur

All Answers

Amit Singh RathaurAmit Singh Rathaur
Hi Mike,

Use '+' in your alert, you are using ' ,' in alert

Use below code of snippet in your code and your alert will be shown the value

alert('cmp.find(input1) = '+ c.find('input1').get('v.value'));

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,

Amit Singh Rathaur
This was selected as the best answer
Mike O.Mike O.
Thank you Amit, so stupid of me and so ashamed I missed it.