I need to fetch value of a checkbox which is present in multifield. There is another checkbox and both the checkboxes are having same granite:class. So I am unable to use granite:class to fetch the value of the checkbox. What else ways are possible to fetch the value of the first checkbox?
Cant use this: let ctaDropdown = $(this).find(".cq-dialog-checkbox-showhide")[0].selectedItem.value;
since my other checkbox is also having same class (cq-dialog-checkbox-showhide)
Solved! Go to Solution.
Views
Replies
Total Likes
You can read the first checkbox value by using the below line of code:
var checkValue = $(this).find(".cq-dialog-checkbox-showhide").eq(0).find(".coral3-Checkbox-input").is(":checked")
alert(checkValue);
Complete logic will be like this:
(function ($, document, ns) {
$(document).on("dialog-ready", function () {
$(".coral3-Multifield-item").each(function (index) {
var firstCheckValue = $(this).find(".cq-dialog-checkbox-showhide").eq(0).find(".coral3-Checkbox-input").is(":checked")
console.log(firstCheckValue);
})
});
})(Granite.$, document, Granite.author);
Hope this helps!
Thanks
You can read the first checkbox value by using the below line of code:
var checkValue = $(this).find(".cq-dialog-checkbox-showhide").eq(0).find(".coral3-Checkbox-input").is(":checked")
alert(checkValue);
Complete logic will be like this:
(function ($, document, ns) {
$(document).on("dialog-ready", function () {
$(".coral3-Multifield-item").each(function (index) {
var firstCheckValue = $(this).find(".cq-dialog-checkbox-showhide").eq(0).find(".coral3-Checkbox-input").is(":checked")
console.log(firstCheckValue);
})
});
})(Granite.$, document, Granite.author);
Hope this helps!
Thanks
Views
Replies
Total Likes
:eq() is a selector that selects an element with a specific index number.
The index number will start at 0, so the first element will have the index number 0.
Thanks!
Views
Replies
Total Likes
Views
Replies
Total Likes