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
GAURAV SETHGAURAV SETH 

I have list of checkboxes on my screen where user can select multiple checkboxes . I do have a submit button which should check if checkbox is selected or not

I am trying to check if checkbox is selected by user or not . but I am getting error while fetching the checkbox component. I am using the code like :
Test.cmp code : On load I need to check if value of innerMap.Value[0] is true or not.then disable the checkboc if already true.

<aura:if isTrue="{!innerMap.Value[0]}">
           
            <ui:inputCheckbox aura:id="checkbox1" name="checkbox-89"  disabled="true" value = ""/>
              <label class="slds-checkbox__label" for="checkbox">
                <span class="slds-checkbox_faux"></span>
                <span class="slds-form-element__label">8AM</span>
              </label>
          <aura:set attribute="else">
            <ui:inputCheckbox aura:id="checkbox1" name="checkbox-89" value = "" />
                  <label class="slds-checkbox__label" for="checkbox">
                    <span class="slds-checkbox_faux"></span>
                    <span class="slds-form-element__label">   8AM    </span>
                  </label>
        </aura:set>
    </aura:if>

<td><lightning:button label="Submit" 
                                          class="slds-m-top--medium"
                                          variant="brand"
                                          onclick="{!c.callConfirmation}"/> </td>

TestController.js 

callConfirmation: function(component, event, helper) {
 var checkbox1 = component.find("checkbox1").get("v.value");
}
I am getting below error when I click on Submit Button.
This page has an error. You might just need to refresh it.
Action failed: c:AvailableUsers$controller$callConfirmation [component.find(...).get is not a function]
Failing descriptor: {c:AvailableUsers$controller$callConfirmation}

Can someone please help me ? what wrong I am doing? I try finding the solution but find that people have used same type of code.
 
Sanjay Bhati 95Sanjay Bhati 95
Hi Gaurav

I checked your code and its correct please check your other part of component. Here I am supposed to true the 
<aura:if isTrue="true">
        
        <ui:inputCheckbox aura:id="checkbox1" name="checkbox-89"  disabled="true" value = ""/>
        <label class="slds-checkbox__label" for="checkbox">
            <span class="slds-checkbox_faux"></span>
            <span class="slds-form-element__label">8AM</span>
        </label>
        <aura:set attribute="else">
            <ui:inputCheckbox aura:id="checkbox1" name="checkbox-89" value = "" />
            <label class="slds-checkbox__label" for="checkbox">
                <span class="slds-checkbox_faux"></span>
                <span class="slds-form-element__label">   8AM    </span>
            </label>
        </aura:set>
    </aura:if>
    
    <lightning:button label="Submit" 
                      class="slds-m-top--medium"
                      variant="brand"
                      onclick="{!c.callConfirmation}"/>

The above code is working fine. Please check it.