Hello,
I found your swap div code very helpful.
What I am trying to do is create a list of links in the left div that navigate through content in the right div. I would like, for example, when the user clicks 'Link B' at the top, that 'Menu B' appears in the left div and 'Content B' appears in the right div, etc. Also, I would like the first option (A) to automatically appear in both divs.
Almost everything works - my only problem now is that the left div default content doesn't show on load.
Here is my javascript:
Code:
<script type="text/javascript">
var currentDiv = null;
var currentDivB = null;
function swapin(divName){
if(currentDiv != null){
document.getElementById(currentDiv).style.display = "none";
}
if(document.getElementById != 'm1'){
document.getElementById('m1').style.display = "none";
}
currentDiv = divName;
document.getElementById(currentDiv).style.display = "block";
}
window.onload = function(){
document.getElementById('m1').style.display = "block";
}
function swapinB(divNameB){
if(currentDivB != null){
document.getElementById(currentDivB).style.display = "none";
}
if(document.getElementById != 'c1'){
document.getElementById('c1').style.display = "none";
}
currentDivB = divNameB;
document.getElementById(currentDivB).style.display = "block";
}
window.onload = function(){
document.getElementById('c1').style.display = "block";
}
</script>
Here is my code for the menu:
HTML Code:
<div id="m1" style="display: none;"> A Links <!-- end #m1 --></div>
<div id="m2" style="display: none;"> B Links <!-- end #m2 --></div>
<div id="m3" style="display: none;"> C Links <!-- end #m3 --></div>
Here is my code for the content:
HTML Code:
<div id="c1" style="display: none;"> A Content <!-- end #c1 --></div>
<div id="c2" style="display: none;"> B Content <!-- end #c2 --></div>
<div id="c3" style="display: none;"> C Content <!-- end #c3 --></div>
And this is how the swaps are called:
HTML Code:
<a href="javascript: swapin('m1'); swapinB('c1')">A</a>
<a href="javascript: swapin('m2'); swapinB('c2')">B</a>
<a href="javascript: swapin('m3'); swapinB('c3')">C</a>
When the page loads, "C1" appears in the right place but the place holder for "M1" is empty. All buttons work properly. Any suggestions?
Thanks much!
Bookmarks