Log in

View Full Version : javascript help - latest posts


BlackJacket
10-03-2009, 03:41 PM
Is this correct?

ctr = 0;
for (x in threads)
{
document.writeln("<a href=\"showthread.php?t="+threads[x].threadid+"\">"+threads[x].title+"</a><br />");
ctr++;
if (ctr == 8)
{
break;
}
}


I keep getting an error and my latest threads wont display right.
Thanks for the help.

Lynne
10-03-2009, 06:39 PM
It always helps if you post the actual error you are getting.

See this thread - http://www.vbulletin.com/forum/showthread.php?t=283817

BlackJacket
10-03-2009, 07:03 PM
It always helps if you post the actual error you are getting.

See this thread - http://www.vbulletin.com/forum/showthread.php?t=283817

Thank you again Lynne.


***To fix this issue***

Enable external javascript

AdminCP>VB Options>External Data Provider>

I also had to fix the JS as it was not correct -

<!--
for (var x in threads)
{
document.writeln("<a href=\"showthread.php?t="+threads[x].threadid+"\">"+threads[x].title+"</a> (Posted By: "+threads[x].poster+")<br />");
}
//-->

kevcj
10-04-2009, 03:19 AM
Here, try this, its the code I use on my site. This will display the most recent 15 threads.


<script type="text/javascript" src="http://www.YOURSITENAME.com/forum/external.php?&type=js"></script>
<script language="" type="text/javascript">
<!--
for (x = 0; x < 15; x++)
{
document.writeln("*<a href=http://www.YOURSITENAME.com/forum/showthread.php?t="+threads[x].threadid+">"+threads[x].title+"</a><br />");
}
//-->
</script>

That came straight off the sidebar of my wordpress blog, so it should work.

Lift for Life
10-12-2009, 12:17 AM
Thanks for the code above,,, I've spent the better part of the day trying to get recent posts to show up on an html page and this one did the trick.

Thanks!

Lift