0

I have used a Content Editor web part to display a scroll-down list of links.

The code I use is similar to this:

<select id="mySelect" jquery110205452414735412181="1"  jquery110209014758248214869="1" jquery1102046470813132006583="1"> 
 <option value="-">-</option> 
 <option value="http://www.google.com">Google</option> 
 <option value="http://www.facebook.com">Facebook</option> 
</select> 
<script src="http://code.jquery.com/jquery-1.10.2.min.js">
 </script><script type="text/javascript">

$(document).ready(function() {
  $("#mySelect").change(function(){ 
     if ($(this).val()!='') { 
         window.location.href=$(this).val(); 
          } 
     }); 
});
</script> 

How can I implement a little "add" button that allows a user to easily add links to this list? I would not like to use a "link-list" web part.

2
  • You want to add options to the select? Is that what you mean?
    – Keerthi
    Jul 13, 2015 at 18:11
  • I just want to add a little button perhaps next to the title that allows users to add more links to the list. EDIT: Yes that is what I mean but using a simple interface in the browser
    – Julio
    Jul 13, 2015 at 18:12

1 Answer 1

0

I recommend you to use a simple interface like your propose, but store the links in a custom list.

You can use Client Object Model, which is an API to interact with SharePoint using only JavaScript.

You can see samples in MSDN in this link:

Complete basic operations using JavaScript library code in SharePoint 2013

Form this article, this is an extract of the example "Create, update, and delete list items":

function createListItem(siteUrl) {
    var clientContext = new SP.ClientContext(siteUrl);
    var oList = clientContext.get_web().get_lists().getByTitle('Announcements');

    var itemCreateInfo = new SP.ListItemCreationInformation();
    this.oListItem = oList.addItem(itemCreateInfo);
    oListItem.set_item('Title', 'My New Item!');
    oListItem.set_item('Body', 'Hello World!');
    oListItem.update();

    clientContext.load(oListItem);
    clientContext.executeQueryAsync(
        Function.createDelegate(this, this.onQuerySucceeded), 
        Function.createDelegate(this, this.onQueryFailed)
    );
}

function onQuerySucceeded() {
    alert('Item created: ' + oListItem.get_id());
}

function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + 
        '\n' + args.get_stackTrace());
}

Your Answer

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

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