Page 1 of 1

Multiple Choice

Posted: 22 Apr 2013
by ChrisMBS
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');

Re: Multiple Choice

Posted: 23 Apr 2013
by Dmitry Kozlov
You can iterate through all options and find selected. Here is an example:

Code: Select all

$.each(fd.field('Checkboxes').control()._el()
  .find('input[type="checkbox"]'), function(i, el) 
{
  if ($(this).is(':checked')) {
    alert(i + ' option is selected');
  }
});

Re: Multiple Choice

Posted: 24 Jan 2014
by schuess
I want to run some actions IF a certain checkbox in a multi-selection input type .is(':checkedsmile 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!