Multiple Choice

rss

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');
  • Dmitry
    Dmitry
    Admin
    Member for: 10 years 9 months 16 days
    #1 by Dmitry Apr 23 ’13 at 02:36

    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');
      }
    });
    
  • schuess
    schuess
    Member
    Member for: 9 years 2 months 2 days
    #2 by schuess Jan 24 ’14 at 05:18

    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!

Displaying 1 to 2 of 2 messages