Skip navigation
Tombocasey2012
Currently Being Moderated

Linking Div Tags

Nov 26, 2012 2:32 AM

Tags: #cs4 #cs5 #cs3 #error #background #image #flash #internet #jquery #mac #files #html #mobile #install #javascript #link #links #spry #css #form #layout #phonegap #ie #html5 #cs6 #ftp

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

 
Replies
  • Currently Being Moderated
    Nov 26, 2012 4:15 AM   in reply to Tombocasey2012

    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.

     
    |
    Mark as:
  • Sudarshan Thiagarajan
    4,000 posts
    Oct 15, 2010
    Currently Being Moderated
    Nov 26, 2012 6:51 AM   in reply to Tombocasey2012

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 26, 2012 2:07 PM   in reply to Tombocasey2012

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points