Last active
September 11, 2016 04:50
-
-
Save Microsofttechies/acd95a15df73f23f2fca72b82d39e44c to your computer and use it in GitHub Desktop.
SharePoint Online Pull values from a lookup column using SPServices()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <head> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices.min.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> | |
| </head> | |
| <script> | |
| $(document).ready(function () { | |
| //With out ID | |
| $().SPServices({ | |
| operation: "GetListItems", | |
| async: false, | |
| listName: "Country", | |
| CAMLViewFields: "<ViewFields><FieldRef Name='Title'/></ViewFields>", | |
| completefunc: function (xData, Status) { | |
| $(xData.responseXML).SPFilterNode("z:row").each(function () { | |
| var liHtmlbi = "<option><a href='#' title=''>" + $(this).attr("ows_Title") + "</a></option>"; | |
| $("#country").append(liHtmlbi); | |
| }); | |
| } | |
| }); | |
| //With ID | |
| $().SPServices({ | |
| operation: "GetListItems", | |
| async: false, | |
| listName: "Country", | |
| CAMLViewFields: "<ViewFields><FieldRef Name='ID'/><FieldRef Name='Title'/></ViewFields>", | |
| completefunc: function (xData, Status) { | |
| $(xData.responseXML).SPFilterNode("z:row").each(function () { | |
| var liHtmlbi = "<option value='" + $(this).attr("ows_ID") + "'>" + $(this).attr("ows_Title") + "</option>"; | |
| $("#country").append(liHtmlbi); | |
| }); | |
| } | |
| }); | |
| }); | |
| </script> | |
| <body> | |
| <table> | |
| <tr><td>Country</td><td><select id="country" style="max-width:90%;"></select></td></tr> | |
| </table> | |
| </body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment