Use SPDisplayRelatedInfo to apply a choice to a complex (> 20) pulldown

Mar 17, 2011 at 7:19 PM
Edited Mar 17, 2011 at 7:19 PM

I have used the SPCascadeDropdowns to take a choice from one pulldown and apply it to another pulldown.  However, since the filtered list in the second pulldown will only produce one choice, I decided that the SPDisplayRelatedInfo would be a better use.  I have everything working to the point of getting the information from completefunc, but I'm kind of stumped about how to apply the choice to the second pulldown menu.  The complex pulldown will not accept the value setting, so I wondered if there was a normal way to do this.  I'm still feeling my way around jQuery with Sharepoint, but I thought this might have been something easier than I was making it. 

I have a value now, I just need to apply it to a complex pulldown menu:

 

ctlTA is the ID of the complex pulldown control.  I see the data with the alert, but it doesn't get applied to the control.

 

Thanks for any advice!

 


  

  function showTA(){
        var valTA = $('div#SPDisplayRelatedInfo_DrugName tr:odd td:first').html();
    if (valTA != "" ) {
     alert(valTA);
             $('ctlTA').value = valTA;
  }
  }


Coordinator
Mar 22, 2011 at 6:16 PM

Sorry; I just found your unanswered question. So you're trying to grab the result shown in the output from SPDisplayRelatedInfo and stuff it into a 20+ option dropdown? They are a bit of a pain.

M.

Mar 24, 2011 at 2:55 PM

Thank you for checking.  I ended up adding a text control and using the javascript plugin by Alexander Bautz to set the value.  Do you know of any example of applying a value, or preloading a selection into one of the 20+ option dropdowns? 

Thanks again,

Paul

Mar 24, 2011 at 3:24 PM
Edited Mar 24, 2011 at 3:26 PM

Here's a script that I use.  It'll set a value to the drop down of your choice.  It doesn't matter if it's equal to or less than 19 items or equal to 20 items or greater.  Just pass in your columnName and your value.

 

function SetLookupVal( columnName, lookupVal ) {
	if ( $("select[title='" +columnName + "']").html() !== null ) {
	   $( "select[title='"+ columnName +"']" ).val( lookupVal );	
	}
	else {
		$( "input[title='" + columnName +"']" ).val( lookupVal );	
	}
};