SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a list with a column that contains a url. For exmaple:


ID          Name        URL
1           MSN


Now, what I need to do is pull the value in the URL column and pass it to a link in a content editor webpart. For example:

--Content Editor Webpart HTML--

<a href="{value in column 3}">MSN</a>


Is this possible? I would imagine it might be using Javascript. Thanks in advance for any information!!

share|improve this question
What's the point of using a Content Editor Web Part? Why not display it in a SharePoint list? – Christophe Apr 6 '12 at 20:36

Here is a blog post that talks about how to add JavaScript to the CEWP.

But I like to use the HTML Form Web Part for this myself.

Now it comes down to how to get the link. Without knowing the criteria you wish to use to pick the row from the list it is hard to give you a very good example. But here is something to get you started.

Notice I like to use JQuery in my SharePoint pages... You might need to Google how to add JQuery to your pages.


    var context = new SP.ClientContext.get_current();
    var list = "Name of List";
    var view = "Name of View;
        list = context.get_web().get_lists().getByTitle(listTitle); 
        view = list.get_views().getByTitle(viewTitle); 

        function(sender, args) {getLinkListItem("<View><Query>" + view.get_viewQuery() + "</Query></View>")}, 
        function(sender, args) {alert("error: " + args.get_message());} 

    }, 'sp.js')});

 function getLinkListItem(camlQuery){
      var context = SP.ClientContext.get_current();
      var approvalList = context.get_web().get_lists().getByTitle(listTitle);

      var query = new SP.CamlQuery(); 

      listItems = approvalList.getItems(query);

      context.executeQueryAsync(ReadListItemSucceeded, ReadListItemFailed);

function ReadListItemSucceeded(sender, args) {
  var itemsString = '';
  var enumerator = listItems.getEnumerator();

  //Use this while to populate your link tags with the proper URLs.
  while (enumerator.moveNext()) {
    var listItem = enumerator.get_current();
    var link = listItem.get_item('URL').toString();
    //Logic here.

function ReadListItemFailed(sender, args) {
  alert('Request failed.');

Here are some links on the JavaScript Client Object Model you will find useful in modifying your script.

share|improve this answer

Hi you can also use webservice for getting listitem.

try this in your content editor webpart

    <div class="testing"></div>

create one div for append links

insert script after that

<script type="text/javascript">    
function processResult(xData, status) {
       $(xData.responseXML).find("z\\:row").each(function() {

             var title = $(this).attr("ows_Title");
             var url = $(this).attr("ows_Url");
             $('.testing').append("<a href="+url+">"+title+"</a>");


   $(document).ready(function() {
       var soapEnv =
           "<soapenv:Envelope xmlns:soapenv=''> \
               <soapenv:Body> \
                    <GetListItems xmlns=''> \
                       <listName>YourListname</listName> \
                       <viewFields> \
                           <ViewFields> \
                              <FieldRef Name='Title' /> \
                              <FieldRef Name='Url' /> \
                          </ViewFields> \
                       </viewFields> \
                   </GetListItems> \
               </soapenv:Body> \
           url: "/_vti_bin/lists.asmx",
           type: "POST",
           dataType: "xml",
           data: soapEnv,
           complete: processResult,
           contentType: "text/xml; charset=\"utf-8\""

share|improve this answer
Can you comment on the purpose of the soapEnv and how it functions? – RyanS Apr 10 '12 at 19:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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