soddengecko Posted October 28, 2007 Share Posted October 28, 2007 hi all I am loading my content externally into a div to show recent updates to my site. at the moment i am deleting old entries so that i am only showing 10 updates at a time. the data is a simple list of items. is it possible to have javascript go through this list and only output only the first ten entries in the <ul>? Quote Link to comment Share on other sites More sharing options...
mainewoods Posted October 30, 2007 Share Posted October 30, 2007 are you saying that the items currently are in an ul, or that you want to output them in an ul? is the list being recieved through ajax? what form is it being recieved in: json, comma separated, newline separated, etc. You will probably have to write some code to break the individual items out and create an array, then you can just use a loop to build the list, then innerHTML: <script> var myUL = '<ul>'; for (var i=0; i<10; i++) { myUL += '<li>' + listitem[i] + '</li>'; } myUL += '</ul>'; document.getElementById('myDIV').innerHTML = myUL; </script> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.