Can I call Javascript from outline or do you have a better idea

I have a form that contains over 40 “pages” that are each separated by

tags. It was built using Stan’s Next/Back button functionality (it is such an easy process that it was a no brainer to use).

Now I have a problem where the design calls for an outline (or some other method) to allow the user to select any of the pages and go to that page instead of having to press Next x times.

The Next button is

Next

The JS code that controls which page is

var currentPage = 1;

var firstPage = 1;

var lastPage = 41;

function flipPage(toPageNumber) {

document.getElementById(‘page_’ + currentPage).style.display = ‘none’;

document.getElementById(‘page_’ + toPageNumber).style.display = ‘block’;

toPageNumber > currentPage?currentPage++:currentPage–;

document.getElementById(‘backButton’).disabled = (currentPage == firstPage)?true:false;

document.getElementById(‘nextButton’).disabled = (currentPage == lastPage)?true:false;

}

I was thinking of using an Outline but I am not sure how to get it to switch to the proper Div tag.

Does anyone have a better method to accomplish this functionality (a one step click to get to a specific page) or a way to use an outline to do what I want?