0

I have this code

var listTitle = [];
var listUrl = [];
var listItemEnumerator = collListItem.getEnumerator();

while (listItemEnumerator.moveNext()) {
    var oListItem = listItemEnumerator.get_current();
    listTitle += oListItem.get_item('Title');
    listUrl =  oListItem.get_item('PrivacyStatementUrls').get_url() ;
}

I am wanting to put each item of the list as a single item in an array and then make the url the title for each list item like so:

    var test = ''

for(i=0; i<listTitle.length;i++)
{

test +='<a href="'+listUrl[i]+'">'+listTitle[i]+'</a>'      
}

document.getElementById('test').innerHTML =  test;

Doing this I found that my code only prints a letter at a time and doesn't place each list item as a single array item. How can I do this

0

Try Following:

listTitle.push(oListItem.get_item('Title'));
listUrl.push(oListItem.get_item('PrivacyStatementUrls').get_url());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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