Forums

Hide/show pages with javascript (2 posts)

  1. alessandro.baffa
    Member
    Posted 4 years ago #

    Hi everybody, i don't know if it's right to write here this kind of problem, so i try ..
    I'd like to insert a javascript effect in my WordPress template, in such a way that it is possible to click on menu items and change only a DIV just after the menu.
    I'll try to explain better what i mean.
    I have a menu with this kind of links
    <a href="javascript:;" onmousedown="toggleDiv('slickbox');" title="Browse the archives">browse</a>,
    toggleDiv is a call to a javascript function, which is the following:

    function toggleDiv(divid){
    
      if(document.getElementById(divid).style.display == 'none'){
    	document.getElementById(divid).style.display = 'block';
      }else{
        document.getElementById(divid).style.display = 'none';
      }
    }
    .
    This function takes the divid parameter, finds the DIV with this id attribute and makes it visible. The DIV code is the following:
    <div id="about" style="display:none;">
    		<div id="slickcats">
    			<ul id="script" class="headcats">
                               HERE WILL BE SOME TEXT
    			</ul>
    		</div>
    </div>
    .

    I have downloaded the "Improved Include Pages" plugin, that allows me to include the content of a page in another one adding a string like this:<?php iinclude_page(11); ?>.
    My target is to have a DIV in my home page that changes its content dinamycally with the link a click, and this content are the pages. But i don't know how to do.
    Now i have as many DIVs as the links in my menu, but i'd like to have only one DIV that dinamically changes.

    There's someone who can help me?
    Thanks!

  2. alessandro.baffa
    Member
    Posted 4 years ago #

    To explain better: i want to have a code made in this way

    <div id="about" style="display:none;">
    		<div id="slickcats">
    			<ul id="script" class="headcats">
                               <?php iinclude_page(DINAMICALLY CHANGES); ?>
    			</ul>
    		</div>
    </div>

    and i'd like to obtain a way to change the <?php ...?> everytime i click in a different link of my menu. I have already tried to change the innerHTML property of the

      tag in the javascript function, but it seems like it doesn't accept a string like this "<?php ... ?>". The script stops putting this string in the innerHTML.

Topic Closed

This topic has been closed to new replies.

About this Topic