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
adarsh johnadarsh john 

Checkbox field value not getting retrieved in the lightning component

Hello all,

I have a checkbox field in my custom registration form for the community users.

Lightning component:

<aura:attribute name="explicitOptIn" type="Boolean" required="false" default="false"/>

<div id="sfdc_opt_in_container" class="sfdc">
               
                <ui:inputcheckbox aura:id="checkbox1" value="{!v.explicitOptIn}" change="{!c.oncheck}" class="input sfdc_explicitOptIn sfdc"/>
                Privacy Policy.
            </div>

Lightning controller Helper

oncheck: function(component,event,helper) {
        var checkbox = component.find('checkbox1').get('v.value');        
        component.set("v.explicitOptIn",checkbox);
    }

I am getting an error as "This page has an error. You might just need to refresh it. Unable to find action 'oncheck' on the controller."

Could somebody please help here on this.
Best Answer chosen by adarsh john
mukesh guptamukesh gupta
HI Adarsh,

i have tried with below code:-
 
<ui:inputCheckbox aura:id="chkbox" class="slds-input" change="{!c.selectChange}"/>
 
({
    selectChange : function(cmp, event, helper) {
        var checkCmp = cmp.find("chkbox");
        cmp.set("v.toggleValue" ,  checkCmp.get("v.value"));
    }
})

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh

All Answers

mukesh guptamukesh gupta
HI Adarsh,

i have tried with below code:-
 
<ui:inputCheckbox aura:id="chkbox" class="slds-input" change="{!c.selectChange}"/>
 
({
    selectChange : function(cmp, event, helper) {
        var checkCmp = cmp.find("chkbox");
        cmp.set("v.toggleValue" ,  checkCmp.get("v.value"));
    }
})

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
This was selected as the best answer
adarsh johnadarsh john
Thanks Mukesh