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
anil Kumaranil Kumar 

Not able to get lightning input type check box values in JS controller

Hi All,

We are replacing ui names space tags with lightning name space tag in the lightning component since they are going to deprecating soon.
We are displaying multiple languages with checkbox’s . When users selects check box language value should update in backend. While using ui:inputCheckbox tag we are able to update the  language but if we use  lightning:input type="checkbox" language values updating as Boolean value (True) in the back end instead of check box values. Below is the peace of code.

Component :
<aura:attribute name="selectAllLanguages" type="Boolean" default="false" />
  <aura:attribute name="languages" type="Object[]" />
 <aura:iteration items="{!v.languages}" var="lang">
  <lightning:input type="checkbox"  value="{!lang.isSelected}" aura:id="boxPackLanguages" />
   <!--<ui:inputCheckbox text="{!lang.language}" value="{!lang.isSelected}" aura:id="boxPackLanguages" />-->

</aura:iteration>

JS:

var languagesSelected = false;
var getAllLanguages = component.find("boxPackLanguages");
   if(getAllLanguages != null){
            //if there's only one language
            if (getAllLanguages[0] == null) {
                languagesSelected = true;
                languages.push(getAllLanguages.get("v.value"));
            }
           
            for (var i = 0; i < getAllLanguages.length; i++) {
                if (getAllLanguages[i].get("v.value") == true) {
                    languagesSelected = true;
                    languages.push(getAllLanguages[i].get("v.value"));
                }
            }
        }    
ANUTEJANUTEJ (Salesforce Developers) 
Hi Anil,

Have you tried checking with lightning:checkboxGroup once, below is the link to the documentation link,

>>  https://developer.salesforce.com/docs/component-library/bundle/lightning:checkboxGroup/example

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
anil Kumaranil Kumar
Hi Anutej,

Thank you for your reply.

I have tried using checkboxGroup checkboxes are not coming . I want use this tag inside aura iteration. 

Thanks,
Anil Kumar