none
How to bind Column of Sharepoint list to dropdown RRS feed

  • Question

  • I want to bind values in column of share point list to the drop down. my drop down is placed on form created in sharepoint designer.

    can any body suggest me aproach i need to apply

    Thursday, April 20, 2017 10:35 AM

All replies

  • Hi,

    You could use REST api to retrieve list items and then bind to dropdown list by jQuery/JavaScript.

    Here is sample code for your reference.

    <script type="text/javascript" src="https://code.jquery.com/jquery-1.7.1.min.js"></script>
        <script type="text/javascript">
            $(function () {
                //the list which you want to query, replace with your own list name.
                var listName = 'Employee';
                $.ajax({
                    // use below REST api to retrive all list items  
                    url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('" + listName + "')/items?$select=ID,Title",
                    type: "GET",
                    headers: { "accept": "application/json;odata=verbose" },
                    success: (function (data, textStatus, jqXHR) {
                        $.each(data.d.results, function (key, value) {
                            // get each item 
                            var ID = value.ID;
                            var title = value.Title;
                            $('#mySelect').append($('<option>', {
                                value: ID,
                                text: title
                            }));
                        });
                    }),
                    error: (function (xhr, ajaxOptions, thrownError) {
                        alert('Request failed: ' + xhr.status + '\n' + thrownError + '\n' + xhr.responseText);
                    })
                });
            });
        </script>
        <select id="mySelect">
            <option>Select One Item...</option>
        </select>

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Friday, April 21, 2017 4:57 AM
  • Hi,

    I am checking to see how things are going there on this issue. Please let us know if you would like further assistance.

    You can mark the helpful post as answer to help other community members find the helpful information quickly.

    You can also share your own solution here and mark it as answer, and we can learn from each other.

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, May 2, 2017 8:45 AM
  • would like to know, if my site column contains spaces , like  my site column name instead of mysitecolumnname

    how to mention the column names in this code : 

    /items?$select=ID,Title",
       url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('" + listName + "')/items?$select=ID,Title",
                    type: "GET",
                    header

    is it internal name? or the usual display name of the column?

    Thursday, November 29, 2018 12:47 PM