Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. Changing the content of a div tag help required

Changing the content of a div tag help required

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
phphelpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    djhankypark
    wrote on last edited by
    #1

    Hello, I am using a div tag in a page called profiles.php whos left content is being brought in by using require_once...

    <div class="divMain_Left">
    <?php require_once('left.php'); ?>
    </div>

    whilst this works fine and I have links in the page left.php that is being fed in to the div, I would like when any of these links are clicked to have it open in the same div tag? I have tried the target options but none of them seem to open within the div tag and they just open a new page. If anybody could point me in the right direction please. Many thanks in advance Regards Ray

    C Y 2 Replies Last reply
    0
    • D djhankypark

      Hello, I am using a div tag in a page called profiles.php whos left content is being brought in by using require_once...

      <div class="divMain_Left">
      <?php require_once('left.php'); ?>
      </div>

      whilst this works fine and I have links in the page left.php that is being fed in to the div, I would like when any of these links are clicked to have it open in the same div tag? I have tried the target options but none of them seem to open within the div tag and they just open a new page. If anybody could point me in the right direction please. Many thanks in advance Regards Ray

      C Offline
      C Offline
      cjoki
      wrote on last edited by
      #2

      Thats how links work, to just have the divs contents refreshed and not the page you have 2 options I can think of. 1) use an frame or iframe. 2) use ajax. Of the two, ajax, is I think the better option.

      1 Reply Last reply
      0
      • D djhankypark

        Hello, I am using a div tag in a page called profiles.php whos left content is being brought in by using require_once...

        <div class="divMain_Left">
        <?php require_once('left.php'); ?>
        </div>

        whilst this works fine and I have links in the page left.php that is being fed in to the div, I would like when any of these links are clicked to have it open in the same div tag? I have tried the target options but none of them seem to open within the div tag and they just open a new page. If anybody could point me in the right direction please. Many thanks in advance Regards Ray

        Y Offline
        Y Offline
        Yvan Rodrigues
        wrote on last edited by
        #3

        What you're trying to do can't be done by inlining the included content with include() or require(). The content that you wish to include will require an additional request to the server for the new content and this will need to be rendered to be browser either using AJAX or an iframe. AJAX would be generally accepted to be the best practice in this case. This is somewhat advanced stuff, but the jQuery library would make this relatively easy. You would assign a function to the onclick event of the link that would "get" the content from the content URL. For more information, see: http://www.w3schools.com/htmldom/default.asp[^] http://api.jquery.com/jQuery.get/[^]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups