This SharePoint 2013 tutorial, we will discuss how to bind SharePoint list items to the dropdown list using the javascript object model (jsom) in SharePoint Online.
We will also see how to bind SharePoint list items to a dropdown list using Rest API as well as using the SharePoint server object model code.
Here I have a custom SharePoint list which has few items in it like below:

Bind SharePoint list items to dropdownlist using javascript/jQuery
Now, we will see how to bind SharePoint list items to a dropdown list in SharePoint using jsom.
We will create an HTML form, .js file and .css file and will display the form inside a web part page using a content editor web part.
HTML File
First of all, we have to create an HTML File, JS File, and CSS File for table designing purposes.
The HTML code is given below-
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://onlysharepoint2013.sharepoint.com/sites/Raju/SiteAssets/Preetihtml/VendorJsFile.js"></script>
<link rel="stylesheet" href="https://onlysharepoint2013.sharepoint.com/sites/Raju/SiteAssets/Preetihtml/VendorStyle.css">
<meta charset="utf-8" />
<title>Vendor List</title>
</head>
<body>
Vendor List: <select name="Vendor" id="MobileVendor"></select>
</body>
</html>
In this HTML Code, I have given the JS path link and as well as the CSS path link.
JavaScript File (.js file)
Now we will create the JavaScript file (.js) which will contain the JavaScript or JSOM (JavaScript object model) code.
$(document).ready(function () {
ExecuteOrDelayUntilScriptLoaded(Bindvendor, "sp.js");
});
var collListItem;
function Bindvendor() {
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('VendorList');
var camlQuery = new SP.CamlQuery();
collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded(sender, args) {
var listItemEnumerator = collListItem.getEnumerator();
$("#MobileVendor").append('<option>---Select Vendor---</option>')
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
$("#MobileVendor").append('<option>' + oListItem.get_item('Title') + '</option>')
}
}
function onQueryFailed(sender, args) {
alert('Error: ' + args.get_message() + '\n' + args.get_stackTrace());
}
}
Here in this JS Code, Within the success method[“function onQuerySucceeded(sender, args)”], We are appending the options to the Drop down. For appending the options, we can write below code-
$("#MobileVendor").append('<option>' + oListItem.get_item('Title') + '</option>')
Where as “#MobileVendor” is the ID attribute for Drop down which is present inside the HTML Code.
.CSS File
I have created a CSS file which will add styling to the dropdown list. The Style code is given below:
#MobileVendor {
padding: 5px;
color: lightcoral;
font-size: 12px;
width: 150px;
}
Now, upload all the files to the SharePoint site assets library.
Then create a web part page in the SharePoint site. Edit the page and add a content editor web part to the web part page in SharePoint.

You may like following jsom SharePoint examples:
- JavaScript in the content editor or script editor web part or not working after publishing the page in SharePoint Online/2013/2016
- Uncaught ReferenceError: the web is not defined Error in SharePoint Online JSOM
- How to get a SharePoint person or group field using javascript (jsom)
- Retrieve SharePoint list items programmatically using jsom, rest API and csom in SharePoint Online/2016/2013
- How to create a list using jsom (JavaScript object model) in SharePoint?
- RSS feed sharepoint 2013 or RSS feed for sharepoint online
Bind SharePoint list items to dropdown list using Server Object Model
We can also easily bind SharePoint list data to a dropdown list using the SharePoint server object model.
if (!Page.IsPostBack)
{
using (SPSite site = new ("https://SiteURL"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["VendorList"];
ddlVendor.DataSource = list.Items;
ddlVendor.DataValueField = "ID";
ddlVendor.DataTextField = "Title";
ddlVendor.DataBind();
}
}
}
Once you run the above code, the items will be bind to the dropdown list in SharePoint 2013/2016.
You may like following SharePoint server object model code examples:
- SharePoint 2013: Add, Delete and Display User Custom Actions using SharePoint Server Object Model
- Add SharePoint 2016/2013 List/Library Columns to view programmatically using the server object model in Visual Studio 2017
- Difference between the client-side object model and the server-side object model in SharePoint 2013/2016/Online
- Create a Document Library with Columns programmatically in SharePoint 2016/2013 using Visual Studio 2017
- Create Site Columns programmatically in SharePoint 2016/2013 using Server Object Model in Visual Studio 2017
Bind SharePoint list items to dropdownlist using Rest API
In this section, we will discuss how to bind the dropdown from the SharePoint list using Rest API.
Below is the code to bind SharePoint list items to dropdown list using Rest API.
<select id="idDepartment" name="idDepartment"></select>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('Departments')/items";
$.ajax({
url: requestUri,
type: "GET",
headers: {
"accept":"application/json; odata=verbose"
},
success: onSuccess,
error: onError
});
function onSuccess(data) {
var allitems='';
var items = data.d.results;
for (var i = 0; i < items.length; i++) {
var optionhtml = '<option value="' + i + '">' + data.d.results[i].Title + '</option>';
$("#idDepartment").append(optionhtml);
}
}
function onError(error) {
alert(JSON.stringify(error));
}
</script>
You can see the output like below:

You may like following SharePoint Rest API tutorials:
- Create, Update and Delete SharePoint List using Rest API in SharePoint 2013/2016/Online
- Retrieve SharePoint list items programmatically using jsom, rest api and csom in SharePoint Online/2016/2013
- SharePoint Branding: Displaying dynamic contents into page using JavaScript and REST API in SharePoint online or SharePoint 2016/2013
- SharePoint Online Branding: Display List items into page using AngularJS and REST Api in SharePoint online or SharePoint 2016/2013
- Bind SharePoint Online List Data into HTML table or jQuery Datatable using jQuery and Rest API
- Rest API filter list items created by logged in user SharePoint Online/2013/2016
- How to make synchronous Rest API call in SharePoint online using jQuery?
Conclusion
This SharePoint tutorial, We discussed how to populate the drop-down list from the SharePoint Online list by using JSOM (JavaScript Object Model).
We also saw, how to bind SharePoint list data to a dropdown list using the SharePoint server object model and we also saw how to bind SharePoint list items to a drop-down list using rest api.
I am Bijay a Microsoft MVP (8 times – My MVP Profile) in SharePoint and have more than 15 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com