You need to sign in to do that
Don't have an account?
Sid Lightning
Enable and disable lightning input field based on checkbox?
Hi,
I have a special discount , However thing is if that discount field gets applied all other fields should get disabled.
I am thinking to apply a checkbox "special discount". Once that gets filled in. all other fields gets disabled and only special discount text field gets enabled.
All fields are lightning input
How can i do it in lightning ?
I have a special discount , However thing is if that discount field gets applied all other fields should get disabled.
I am thinking to apply a checkbox "special discount". Once that gets filled in. all other fields gets disabled and only special discount text field gets enabled.
All fields are lightning input
How can i do it in lightning ?
Can you try below below to hide lightning:input fileds. Let me know if it didnt work for you.
All Answers
Can you try below below to hide lightning:input fileds. Let me know if it didnt work for you.
Try the following code it works for you: I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
To get the checkbox value in Showhide function, you need to use event.getSource().get('v.value').
And with component.find("disableenable") you can get the button for disabling or you can have an additional attribute store the state and use it. I like the component.find way.
Here is the controller method in action:
({
Showhide : function(component, event, helper) {
let checkBoxState = event.getSource().get('v.value');
console.log(event.getSource().get('v.value'));
component.find("disableenable").set("v.disabled", !checkBoxState);
}
})
Component :
<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
<ui:inputCheckbox aura:id="checkbox" change="{!c.Showhide}" />
<p>I have read and agree to the Terms </p>
<lightning:button variant="brand" label="Continue" aura:id="disableenable" disabled="true"/>
</aura:component>
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
Can you please help me in my other questions