Multiple Choice

Discussions about Forms Designer for SharePoint 2010.
Locked
ChrisMBS
Posts: 4
Joined: Wed Jun 19, 2013

22 Apr 2013

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');

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

23 Apr 2013

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');
  }
});

User avatar
schuess
Posts: 82
Joined: Wed Jan 22, 2014

24 Jan 2014

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!

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests