I am trying to pass a variable from one page to another using JavaScript so that the following works:
main.html:
<html>
<head>
</head>
<body>
<p>Links to worksheets:  
<a href="worksheets.html" >1  
<a href="worksheets.html">2  
<a href="worksheets.html">3  
</body>
</html>
worksheets.html:
<html>
<head>
</head>
<body>
<p id="mainParagraph"></p>
<script>
document.getElementById("mainParagraph").innerHTML = "This is worksheet number " + localStorage.getItem("worksheetNumber");
</script>
</body>
</html>
What I am needing is a way for the main file to pass the worksheet number to local storage. I would like to do this without having a separate JavaScript method for each worksheet, as I intend to have hundreds of worksheets. Another option may be to have an inline JavaScript method for each link, but I can’t get anything to work.
Can anyone suggest a way to pass the worksheet number when the link is clicked? Local storage seems to be a good way to do it, but I’m open to other ways of doing it with JavaScript.
Thank you.