So to be quick and to the point, I'm attempting to create a small vertical menu on the left side of my screen where when you click on an item in the list, it changes all the contents of a div to the right of it, the 'content' section but without changing the physical html file. Meaning, I'd like to keep it all as one document and do it with JavaScript as I've seen used before.
Here's a 'mock-up' of what I'd like to do:
EDIT/UPDATE
Alright so I've found a solution that works, but I've got 2 things I want to change with it and I'm not sure how.
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
I want to add the following:
- Only one can display at a time
- Some sort of 'slide' animation for changing 'screens'
Here's an example currently on how the links work:
<a onclick="toggle_visibility('2');">Testing</a>
<div style="display:none;" id="2">
testing for page 2
</div>