3 Replies Latest reply: Nov 26, 2012 2:07 PM by Nancy O. RSS

    Linking Div Tags

    Tombocasey2012

      Is there any way you can link a Div tag on one page to a Div Tag on another page, so that when you change one thing on one Div tag, It will automatically change on the other Div tag on the other page?

       

      CS5

       

      Thanks

        • 1. Re: Linking Div Tags
          Ben Pleysier MVP

          The only way to achieve this is to use a database (flat or relational, e.g. a file or MySQL). Then use serverside code to show the content on each page.

          • 2. Re: Linking Div Tags
            sudarshan.t MVP

            Tombo,

             

            Assuming you want to update content in one place and have it displayed in all areas that use the same content, you can use php include to do this.

             

            For example, if this is the content you want on both div's on 2 different pages:

             

            <div id="test">

            <p>Test content</p>

            </div>

            You can put that code into a .php file - something like test.php. And let's say you have home.php and services.php where you want the same content to be displayed, add this line of code in both the pages:

             

            <?php include('test.php'); ?>

             

            This will include the contents within test.php file in the section where you've inserted the <?php include...> code.

             

            Note: Your files should be .php for the php includes to work.

            • 3. Re: Linking Div Tags
              Nancy O. MVP

              Divs don't communicate with each other. They are nothing more than placeholders for content (headings, paragraphs, lists, links, etc...). 

               

              Depending on how you build your site, content inside divs can be static (plain HTML) or dynamic (generated by the server from commands in your code).

               

              I think for what you're after, you should look at iframes (a page within a page) or server-side includes (a file within a page).

               

               

              Nancy O.