[code]<html>
<head>
<script type=”text/javascript”>
function listPages()
{
var i = 0; var page, currentPage;
while(i < 25)
{
i++;
if(document.getElementById(“page” + i) != null)
{
if(document.getElementById(“page” + i).style.display != “none”)
currentPage = i;
}
}
alert(currentPage);
}
</script>
<style type=”text/css”>
.page
{
display: none;
}
</head>
<body>
<div id=”page1″>Page 1</div>
<div id=”page2″ class=”page”>Page 2</div>
<div id=”page3″ class=”page”>Page 3</div>
<a href=”javascript:nextPage();”>Go to the next page</a>
</body>
</html>
Obviously I didn’t include all my code, which is very messy and extraneous to the question. The trouble is, i returns as undefined. I want i to return as the “current page,” which is the page that is currently displayed. As you cycle through the pages, the currently displayed page should be i. When you first load the page, i should return 1 since the page1 DIV is not hidden, but it never returns true.
Why? Can someone help me with this? It’s extremely frustrating.