Load page content based on menu using simple javascript

Here i have used a javascript function that will display blcok based on the menu that you clicked .
Paste the below given code in ┬ápage and load that so as to get a better idea of how it works . 

<script type=”text/javascript”>
function NextPage($pageID){
for($i=1;$i<=3;$i++){
if(Number($i)==Number($pageID))
document.getElementById(“page”+$i).style.display=’block’
else
document.getElementById(“page”+$i).style.display=’none’
}
}
</script>
<table>
<tr>
<td>
<a href=”javascript:NextPage(‘1’);”>Page1</a>
<a href=”javascript:NextPage(‘2’);”>Page2</a>
<a href=”javascript:NextPage(‘3’);”>Page3</a>
</td>
<td>
<div id=”page1″ style=”display:block”>
<strong> Page 1</strong> <br>
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using ‘Content here, content here’, making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for ‘lorem ipsum’ will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).

</div>

<div id=”page2″ style=”display:none”>
<strong> Page 2</strong> <br>
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using ‘Content here, content here’, making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for ‘lorem ipsum’ will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).

</div>

<div id=”page3″ style=”display:none”>
<strong> Page 3</strong> <br>
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using ‘Content here, content here’, making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for ‘lorem ipsum’ will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).

</div>
</td>
</tr>
</table>

Share

Leave a Reply

Your email address will not be published. Required fields are marked *