Skip to main content
added 1414 characters in body
Source Link
//Assuming Column1 is the parent column in sharepoint list and Column2 is child column
<script type="text/javascript" src="filelink/jquery-1.6.1.min.js"></script>
<script language="javascript" type="text/javascript">
var dropdowndropdown1 = document.getElementById('DropDown''DropDown1');   //get dropdwondropdown1 by id
var dropdownArray=[];dropdown2 = document.getElementById('DropDown2');   //get dropdown2 by id
var calldropdown1Array=[];
var dropdown2Array=[];    //populate 1st dropdown
var call1 = $.ajax({
        url: "absolute URL" +  "/_api/Web/Lists/GetByTitle('ListName')/Items?$select=Title"$select=column1",
        type: "GET",
        dataType: "json",
        headers: {
            Accept: "application/json;odata=verbose"
        }
    });
    $.when(callcall1).done(function(data, textStatus, jqXHR) {
        data.d.results.forEach(function(entry) {
            //inserting unique values in dropdowndropdown1
            if (dropdownArraydropdownArray1.indexOf(entry.Titlecolumn1) == -1) { 
                dropdownArraydropdownArray1.push(entry.Titlecolumn1);
                //inserting items into dropdowndropdown1
                    var child = document.createElement("option");
                    child.textContent = entry.Title;column1;
                    child.value = entry.Title;column1;
                    selectdropdown1.appendChild(child);
                }
        });
    });
//populate 2nd dropwon in cascaded format
dropdown1.addEventListener("change", function () {
 while (dropdown2.firstChild) {
    dropdown2.removeChild(dropdown2.firstChild);
}
var call2 = $.ajax({
        url: "absolute URL" +  "/_api/Web/Lists/GetByTitle('ListName')/Items?$select=column2&$filter=column1 eq dropdown1.value",
        type: "GET",
        dataType: "json",
        headers: {
            Accept: "application/json;odata=verbose"
        }
    });
    $.when(call2).done(function(data, textStatus, jqXHR) {
        data.d.results.forEach(function(entry) {
            //inserting unique values in dropdown2
            if (dropdownArray2.indexOf(entry.column2) == -1) { 
                dropdownArray2.push(entry.column2);
                //inserting items into dropdown2
                    var child = document.createElement("option");
                    child.textContent = entry.column2;
                    child.value = entry.column2;
                    dropdown2.appendChild(child);
                }
        });
    });
});                 
</script>           
<script type="text/javascript" src="filelink/jquery-1.6.1.min.js"></script>
<script language="javascript" type="text/javascript">
var dropdown = document.getElementById('DropDown'); //get dropdwon by id
var dropdownArray=[];
var call = $.ajax({
        url: "absolute URL" +  "/_api/Web/Lists/GetByTitle('ListName')/Items?$select=Title",
        type: "GET",
        dataType: "json",
        headers: {
            Accept: "application/json;odata=verbose"
        }
    });
    $.when(call).done(function(data, textStatus, jqXHR) {
        data.d.results.forEach(function(entry) {
            //inserting unique values in dropdown
            if (dropdownArray.indexOf(entry.Title) == -1) { 
                dropdownArray.push(entry.Title);
                //inserting items into dropdown
                    var child = document.createElement("option");
                    child.textContent = entry.Title;
                    child.value = entry.Title;
                    select.appendChild(child);
                }
        });
    });
</script>           
//Assuming Column1 is the parent column in sharepoint list and Column2 is child column
<script type="text/javascript" src="filelink/jquery-1.6.1.min.js"></script>
<script language="javascript" type="text/javascript">
var dropdown1 = document.getElementById('DropDown1');   //get dropdown1 by id
var dropdown2 = document.getElementById('DropDown2');   //get dropdown2 by id
var dropdown1Array=[];
var dropdown2Array=[];    //populate 1st dropdown
var call1 = $.ajax({
        url: "absolute URL" +  "/_api/Web/Lists/GetByTitle('ListName')/Items?$select=column1",
        type: "GET",
        dataType: "json",
        headers: {
            Accept: "application/json;odata=verbose"
        }
    });
    $.when(call1).done(function(data, textStatus, jqXHR) {
        data.d.results.forEach(function(entry) {
            //inserting unique values in dropdown1
            if (dropdownArray1.indexOf(entry.column1) == -1) { 
                dropdownArray1.push(entry.column1);
                //inserting items into dropdown1
                    var child = document.createElement("option");
                    child.textContent = entry.column1;
                    child.value = entry.column1;
                    dropdown1.appendChild(child);
                }
        });
    });
//populate 2nd dropwon in cascaded format
dropdown1.addEventListener("change", function () {
 while (dropdown2.firstChild) {
    dropdown2.removeChild(dropdown2.firstChild);
}
var call2 = $.ajax({
        url: "absolute URL" +  "/_api/Web/Lists/GetByTitle('ListName')/Items?$select=column2&$filter=column1 eq dropdown1.value",
        type: "GET",
        dataType: "json",
        headers: {
            Accept: "application/json;odata=verbose"
        }
    });
    $.when(call2).done(function(data, textStatus, jqXHR) {
        data.d.results.forEach(function(entry) {
            //inserting unique values in dropdown2
            if (dropdownArray2.indexOf(entry.column2) == -1) { 
                dropdownArray2.push(entry.column2);
                //inserting items into dropdown2
                    var child = document.createElement("option");
                    child.textContent = entry.column2;
                    child.value = entry.column2;
                    dropdown2.appendChild(child);
                }
        });
    });
});                 
</script>           
deleted 167 characters in body
Source Link
<script type="text/javascript" src="filelink/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="filelink/jquery.SPServices-0.6.2.min.js"></script>
<script language="javascript" type="text/javascript">
var dropdown = document.getElementById('DropDown'); //get dropdowndropdwon by id
var dropdownArray=[]; //temporary array to get unique
var valuescall in= dropdown
$().SPServicesajax({
        url: "absolute URL" + operation: 'GetListItems'"/_api/Web/Lists/GetByTitle('ListName')/Items?$select=Title",
            asynctype: false"GET",
            webURLdataType: 'web Absoulte Url'"json",
            listNameheaders: 'ListName', //listname{
            completefuncAccept: function (xData, Status) {"application/json;odata=verbose"
        }
    });
    $(xData.responseXML).SPFilterNodewhen('z:row'call).eachdone(function (data, textStatus, jqXHR) {
        data.d.results.forEach(function(entry) {
            //inserting unique values in dropdown
                    if (dropdownArray.indexOf($(this)entry.attr('ows_Title')Title) == -1) { 
                    dropdownArray.push($(this)entry.attr('ows_Title')Title);
                    //inserting items into dropdown
                        var child = document.createElement("option");
                        child.textContent = $(this)entry.attr('ows_Title');Title;
                        child.value = $(this)entry.attr('ows_Title');Title;
                        select.appendChild(child);
                    }
                });
         });
</script>   }
        });
</script>
<script type="text/javascript" src="filelink/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="filelink/jquery.SPServices-0.6.2.min.js"></script>
<script language="javascript" type="text/javascript">
var dropdown = document.getElementById('DropDown'); //get dropdown by id
var dropdownArray=[]; //temporary array to get unique values in dropdown
$().SPServices({
            operation: 'GetListItems',
            async: false,
            webURL: 'web Absoulte Url',
            listName: 'ListName', //listname
            completefunc: function (xData, Status) {
                $(xData.responseXML).SPFilterNode('z:row').each(function () {
                    //inserting unique values in dropdown
                    if (dropdownArray.indexOf($(this).attr('ows_Title')) == -1) { 
                    dropdownArray.push($(this).attr('ows_Title'));
                    //inserting items into dropdown
                        var child = document.createElement("option");
                        child.textContent = $(this).attr('ows_Title');
                        child.value = $(this).attr('ows_Title');
                        select.appendChild(child);
                    }
                });
            }
        });
</script>
<script type="text/javascript" src="filelink/jquery-1.6.1.min.js"></script>
<script language="javascript" type="text/javascript">
var dropdown = document.getElementById('DropDown'); //get dropdwon by id
var dropdownArray=[];
var call = $.ajax({
        url: "absolute URL" +  "/_api/Web/Lists/GetByTitle('ListName')/Items?$select=Title",
        type: "GET",
        dataType: "json",
        headers: {
            Accept: "application/json;odata=verbose"
        }
    });
    $.when(call).done(function(data, textStatus, jqXHR) {
        data.d.results.forEach(function(entry) {
            //inserting unique values in dropdown
            if (dropdownArray.indexOf(entry.Title) == -1) { 
                dropdownArray.push(entry.Title);
                //inserting items into dropdown
                    var child = document.createElement("option");
                    child.textContent = entry.Title;
                    child.value = entry.Title;
                    select.appendChild(child);
                }
        });
    });
</script>           
Source Link

<script type="text/javascript" src="filelink/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="filelink/jquery.SPServices-0.6.2.min.js"></script>
<script language="javascript" type="text/javascript">
var dropdown = document.getElementById('DropDown'); //get dropdown by id
var dropdownArray=[]; //temporary array to get unique values in dropdown
$().SPServices({
            operation: 'GetListItems',
            async: false,
            webURL: 'web Absoulte Url',
            listName: 'ListName', //listname
            completefunc: function (xData, Status) {
                $(xData.responseXML).SPFilterNode('z:row').each(function () {
                    //inserting unique values in dropdown
                    if (dropdownArray.indexOf($(this).attr('ows_Title')) == -1) { 
                    dropdownArray.push($(this).attr('ows_Title'));
                    //inserting items into dropdown
                        var child = document.createElement("option");
                        child.textContent = $(this).attr('ows_Title');
                        child.value = $(this).attr('ows_Title');
                        select.appendChild(child);
                    }
                });
            }
        });
</script>