JavaScript - How to get values of input fields?
I'm new to Salesforce and I'm trying to create a simple component.
I'm trying to get the values for the input field text and checkboxes and so far I can only get the country variable in a way I believe is not correct. The value I get for nif is undefined and the checkboxes return on instead of true or false. This is my code:Component markup
Enter Values
Create Account Lead JS Constroller:
({ handleClick : function(component, event, helper) { console.log(document.getElementById('country').value); console.log(component.find("nif").get("v.nif")); console.log(document.getElementById('checkbox-1').value); console.log(document.getElementById('checkbox-2').value); } })
What is input value in JavaScript? How javascript get value of input? The JavaScript input text property is used to set or return the value of a text input field. The value property contains either the default value that is present upon loading the element, the value entered by the user, or the value assigned by the script
The JavaScript input text property is used to set or return the value of a text input field. The value property contains either the default value that is present upon loading the element, the value entered by the user, or the value assigned by the script For javascript to get value of input you can use the Aura:Ids to get the value for example aura:id="nif" component.find('nif').get('v.value');