I have a filter list, where I select a specific list-item on the displayed list. There are 8 fields that I need to retrieve and load onto html boxes. The user can edit some of these returned values. I then need to populate the values for the Document Library Form from these text boxes. Question: How do I do this with code? I am new to jquery, so a code sample would be really helpful, including all initialisations?

1 Answer 1


You can use REST API to get the list items and populate the values in the document library form. There is a code sample below.

        <b>List Items</b>  
        <br />  
        <select style="height:400px; width:200px" multiple="multiple" id="selectalllistitems"></select>  
<script type="text/javascript">
    $(function () {
            url: "https://testlz.sharepoint.com/sites/wendy2/_api/web/lists/GetByTitle('clist2')/items",
            type: 'GET',
            headers: {
                                    accept: "application/json;odata=verbose"
            success: successHandler,
            error: errorHandler
    function successHandler(data, textStatus, jqXHR) {
        alert("successHandler " + "textstatus:" + textStatus + "data: " + data);

var selectallitems = document.getElementById("selectalllistitems");  
if (selectallitems.hasChildNodes())  
    while (selectallitems.childNodes.length >= 1)   
var display = data.d.results;  
for (var i = 0; i < display.length; i++)  
    var selectitems = document.createElement("option");  
    selectitems.value = display[i].Title;  
    selectitems.innerText = display[i].Title;  


    function errorHandler(xhr, ajaxOptions, thrownError) {
        alert('Request failed: ' + xhr.status + '\n' + thrownError + '\n' + xhr.responseText);

More reference:

Working with lists and list items with REST.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.