Select Option Value

rss

Posted by schuess - Jul 23 ’14 at 04:52

How can I execute an action against each option that has been selected in a multi-selection SharePoint control.

 

fd.field('vidConfRooms').change(function() {
if (fd.field('vidConfRooms').control()._el().value() == '1'){
$('.fd_field[fd_name="atlantaCRRep"]').show();
} else{
$('.fd_field[fd_name="atlantaCRRep"]').hide();
};
});

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 10 months 28 days
    #1 by Dmitry Kozlov Jul 24 ’14 at 10:22

    Hi Matt,

    Do you mean multi-lookup or choce with checkboxes field?

  • schuess
    schuess
    Member
    Member for: 5 years 6 months 26 days
    #2 by schuess Jul 24 ’14 at 10:28

    Multi-lookup

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 10 months 28 days
    #3 by Dmitry Kozlov Jul 25 ’14 at 03:18

    [#2]: Hi Matt,

    Please, try the sample below:

    fd.field('vidConfRooms').change(function() {
    	var selectedOptions = fd.field('vidConfRooms')
    	  .control()._el().find('select:eq(1) option');
    	  
    	for (var i = 0; i < selectedOptions.length; i++) {
    		if (selectedOptions.eq(i).text() == 'Room 1') {
    			alert('Room 1 is selected');
    		}
    	}
    });
    
  • schuess
    schuess
    Member
    Member for: 5 years 6 months 26 days
    #4 by schuess Jul 25 ’14 at 10:36

    an alert in this function doesn't even work.

     

    //Goal for Code Below: When a Conference Room is Selected from the Multi-Selection Lookup List Control, .show() it's corresponding field.

    //(For testing purposes, just try and alert the value selected.)

    //NOT WORKING

    fd.field('vidConfRooms').change(function() {

    var selectedOptions = fd.field('vidConfRooms').control()._el().find('select:eq(1) option');

    alert("change happened");//this never fires

    for (var i = 0; i < selectedOptions.length; i++) {

    if (selectedOptions.eq(i).text() == "Atlanta Office - Conference Room") {

    alert('atlantaCRRep is selected');

    }

    }

    });

  • schuess
    schuess
    Member
    Member for: 5 years 6 months 26 days
    #5 by schuess Jul 25 ’14 at 10:37

    an alert in this function doesn't even work.

     

    //Goal for Code Below: When a Conference Room is Selected from the Multi-Selection Lookup List Control, .show() it's corresponding field.

    //(For testing purposes, just try and alert the value selected.)

    //NOT WORKING

    fd.field('vidConfRooms').change(function() {

    var selectedOptions = fd.field('vidConfRooms').control()._el().find('select:eq(1) option');

    alert("change happened");//this never fires

    for (var i = 0; i < selectedOptions.length; i++) {

    if (selectedOptions.eq(i).text() == "Atlanta Office - Conference Room") {

    alert('atlantaCRRep is selected');

    }

    }

    });

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 10 months 28 days
    #6 by Dmitry Kozlov Jul 28 ’14 at 05:10

    [#5]: Make sure that 'vidConfRooms' is the correct internal name of the field. If so, please, send HTML-source of the form page to [email protected]

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 5 years 10 months 28 days
    #7 by Dmitry Kozlov Jul 29 ’14 at 04:45

    [#6]: Hello Matt,

    Thanks for the provided sources. The internal name of the field is 'vidConfRooms0', please, correct it in your code and it will start working:

    fd.field('vidConfRooms0').change(function() {
    	var selectedOptions = fd.field('vidConfRooms0').control()._el()
    		.find('select:eq(1) option');
    	alert("change happened");
    
    	for (var i = 0; i < selectedOptions.length; i++) {
    		if (selectedOptions.eq(i).text() == "Atlanta Office - Conference Room") {
    			alert('atlantaCRRep is selected');
    		}
    	}
    });
    

    Get information on how to get internal names of fields:

    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/75ca6fab-56f3-4bf4-aae0-2d29821778a2/how-to-get-internal-names-of-columns-in-sharepoint-lists?forum=sharepointdevelopmentlegacy

Displaying 1 to 7 of 7 messages