Multiple Choice
Posted by ChrisMBS - Apr 22 ’13 at 07:36
I located the code for getting multiple choice values in your forum. In the example though you've hardcoded the checkbox index.
How do I get the index of the checkbox that is selected and pass it through to the code?
FD Example
var checkboxIndex = 2; fd.field('MultiChoice').control()._el() .find('input[type="checkbox"]').eq(checkboxIndex) .is(':checked');
Pass in selected checkbox index
var checkboxIndex = <<MultiChoiceSelected>>; fd.field('MultiChoice').control()._el() .find('input[type="checkbox"]').eq(checkboxIndex) .is(':checked');
-
DmitryAdminMember for: 10 years 9 months 16 days
You can iterate through all options and find selected. Here is an example:
$.each(fd.field('Checkboxes').control()._el() .find('input[type="checkbox"]'), function(i, el) { if ($(this).is(':checked')) { alert(i + ' option is selected'); } });
-
schuessMemberMember for: 9 years 2 months 2 days
I want to run some actions IF a certain checkbox in a multi-selection input type .is(':checked
based on the value of that checkbox?
I cannot figure out how to check for the value match
my attempt:
window.$('.fd_field[fd_name="architect"]').hide();
fd.field('contractType').control().change(function(){
if (fd.field('contractType').control()._el().find('input[type="checkbox"]').eq('Rental Agreement').is(':checked')) {
window.$('.fd_field[fd_name="architect"]').show();
fd.field('architect').title().required(true);
} else {
window.$('.fd_field[fd_name="architect"]').hide();
fd.field('architect').title().required(false);
}
});
PS> i could not get your iteration example to work.
window.$.each(fd.field('contractType').control()._el()
.find('input[type="checkbox"]'), function(i, el)
{
if ($(this).is(':checked')) {
alert(i + ' option is selected');
}
});
thanks!