PDA

View Full Version : How to show random posts with javascript on an html page ?


jreuc
12-30-2011, 08:40 AM
I am currently using a javascript code to display the latest posts from the forum on our site's html homepage. I would like to show also random posts from selected subforums. What should I change in this code to achieve this ?

<script type="text/javascript" src="http://www.forum.com/forum/external.php?forumids=26,2,43,44,28,3&type=js"></script>
<script type="text/javascript">
<!--
var max = 10;
if(threads.length < max) max = threads.length;
for(i = 0; i < max; i++)
{
if (threads[i].title.length > 40)
{ threads[i].title = threads[i].title.substring(0, 40) + '...'; }
document.writeln("<li><a href=\"http://www.forum.com/forum/showthread.php?t=" + threads[i].threadid + "\">" + threads[i].title + "</a> (" + threads[i].poster + ", " + threads[i].threaddate + ") </li>");
}
//-->
</script>

vbnewbieuser
10-05-2012, 03:41 PM
I think you need to have a connection from the database first before showing the posts.. Or calling a function from vbulletin..