Click here to Skip to main content
15,937,066 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am creating projects through sharepoint list and in the newform i have a fields which of type lookup. based on the selected value of lookup field the other lookup fields values has to be populated.

Ex: L1 has values a,b,c,d
L2 has values 1,2,3,4,5,6
if i select the L1 values as 'a' then L2 should display only 1,2.
if i select the L2 value as 'b' then L2 should display only 3,4.. so..on.

Please suggest how can it be done with minimal customization like JavaScript..

Thanks in advance!!
Sinisa Hajnal 1-Feb-16 11:56am    
Create lookup column in your L2 that references L1.

Register onchange event for L1 and filter L2 according to selected value.

1 solution

Here is simplified sample (you need jQuery for this, but it can be done without):
	$(document).ready(function () { 
	// hide source if BranchAmbassador not selected	
		var $source = $("select[id^='InitiativeSource']");
// this is your selected L1		
		var $selected = $("select[id^='InitiativeSource'] option:selected");

	function sourceChanged() {
		var $selected = $("select[id^='InitiativeSource'] option:selected");
		if ($selected== null || $selected.val() != 1) {
// here you filter L2 to what you need based on $selected.val()
// create collection from your list items and filter them based on this value

	} // end sourceChanged
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900