I found a script on the internet which displays and hides snippets of code:
function show(shown, hidden,) {
document.getElementById(shown).style.display='block';
document.getElementById(hidden).style.display='none';
return false;
}
<a href="#" onclick="return show('Page1','Page2');">Page 1</a>
<a href="#" onclick="return show('Page2','Page1');">Page 2</a>
My question is, how would I alter this to include more pages?
The only way I could find that worked was this:
function show(shown, hidden1, hidden2, hidden3) {
document.getElementById(shown).style.display='block';
document.getElementById(hidden1).style.display='none';
document.getElementById(hidden2).style.display='none';
document.getElementById(hidden3).style.display='none';
return false;
}
<a href="" onclick="return show('Page1','Page2','Page3','Page4' );">Page 1</a>
<a href="" onclick="return show('Page2','Page1','Page3','Page4' );">Page 2</a>
<a href="" onclick="return show('Page3','Page1','Page2','Page4' );">Page 3</a>
<a href="" onclick="return show('Page4','Page1','Page2','Page3' );">Page 4</a>
...but it seems a little messy. So is there a way to pass 3 pages all at once into the 'hidden' argument in the script?
Thanks!