Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Fetch checkbox value (from within multifield)

Avatar

Avatar
Applaud 25
Level 2
Shaheena_Sheikh
Level 2

Likes

2 likes

Total Posts

96 posts

Correct Reply

1 solution
Top badges earned
Applaud 25
Applaud 5
Affirm 1
Validate 10
Validate 1
View profile

Avatar
Applaud 25
Level 2
Shaheena_Sheikh
Level 2

Likes

2 likes

Total Posts

96 posts

Correct Reply

1 solution
Top badges earned
Applaud 25
Applaud 5
Affirm 1
Validate 10
Validate 1
View profile
Shaheena_Sheikh
Level 2

18-04-2021

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)

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

560 likes

Total Posts

677 posts

Correct Reply

194 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

560 likes

Total Posts

677 posts

Correct Reply

194 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile
asutosh_jena
Level 10

18-04-2021

Hi @Shaheena_Sheikh 

 

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 

Answers (0)