Hi all (first post here!)
I'm hoping someone will be able to help me with a problem I've been trying to work on for a while now... basically the announcements panel is to show only the top five announcements (i.e. the 5 most recent announcements) and retain the rest of them in an archive.
The code for the div in question is:
Code:
<div id="announcements">
<p class="main_text" align="center"><b>Announcements</b></p>
<script type="text/javascript">
var scripts = new Array();
scripts[0] = "<b> Date: 22 Oct </b> <br />details";
scripts[1] = "<b> Date: 24 Oct </b> <br />details";
scripts[2] = "<b> Date: 25 Oct </b> <br />details";
scripts[3] = "<b> Date: 27 Oct </b> <br />details";
scripts[4] = "<b> Date: 28 Oct </b> <br />details";
scripts[5] = "<b> Date: 29 Oct </b> <br />details";
scripts[6] = "<b> Date: 30 Oct </b> <br />details";
document.write("<table>");
scripts=scripts.reverse();
for (i=0;i<5;i++)
{
document.write(scripts[i] + "<br >");
document.write("</td> </tr>");
document.write("</table>");
}
</script>
This prints out the latest 5 announcements. However, I would like to have a button which calls the almost identical script, with the subtle change of scripts length (shown in bold):
document.write("<table>");
scripts=scripts.reverse();
for (i=0; i<scripts.length;i++)
{
document.write(scripts[i] + "<br >");
document.write("</td> </tr>");
document.write("</table>");
}
This would hopefully display every annoucement.
Is there any way I can automatically display the first 5, then when the button is clicked the scripts.length function is executed instead?
Thanks for any help!
Steven
|