Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Dynamically Updating PHP Using JavaScript?

    I've done some googling and have come across some information, but I'm not quite sure how to apply it to my problem.

    I have a PHP page saturna.php with six frames on it using the frameset commands. I would like to somehow make it so that when I click on something in one frame (with one PHP page loaded in it - game.php), it automatically/dynamically updates one of the other PHP pages (inventory.php) in another frame. What will happen is when the thing is clicked on in game.php, an entry will be added to the database, and the second PHP page (which retrieves information from the database) will notice that there is a new relevant record, and will add it to the inventory.php page in the table I have constructed there.

    From my googling it seems I need to use JavaScript to do this, but I'm not quite sure how - any ideas ?

    Thanks very much!

  • #2
    Regular Coder
    Join Date
    May 2009
    Posts
    425
    Thanks
    3
    Thanked 62 Times in 61 Posts
    I'll start off by saying it's probably best to not use frames... but I have a feeling switching over to a dynamic div layout would be too much of a pain and take too long at this point... but it would be worth it.

    That said, I'll focus on how to do it with frames. You'll need to use AJAX and wait for the response from the server to make sure the database has been updated before reloading the other frame. More specifically, the javascript that calls the AJAX function should call another function upon response... and this other function will target the other frame via javascript's DOM (dynamic object model) and reload its location. Something like... top.nameoftheframetoreloadhere.location.reload();
    If you google things like "ajax example" and "javascript reload frame" you should get plenty of helpful results.

  • #3
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tfburges View Post
    I'll start off by saying it's probably best to not use frames... but I have a feeling switching over to a dynamic div layout would be too much of a pain and take too long at this point... but it would be worth it.

    That said, I'll focus on how to do it with frames. You'll need to use AJAX and wait for the response from the server to make sure the database has been updated before reloading the other frame. More specifically, the javascript that calls the AJAX function should call another function upon response... and this other function will target the other frame via javascript's DOM (dynamic object model) and reload its location. Something like... top.nameoftheframetoreloadhere.location.reload();
    If you google things like "ajax example" and "javascript reload frame" you should get plenty of helpful results.
    Can you (or someone else) explain how to do the dynamic div layout thing? I know how div tags work, I've made a similar page using div tags just now. How can I solve my problem using this div layout? Thanks!
    Last edited by KodiTiger; 12-27-2010 at 01:04 PM.

  • #4
    Regular Coder
    Join Date
    May 2009
    Posts
    425
    Thanks
    3
    Thanked 62 Times in 61 Posts
    It's kind of long and complicated... your best bet is to do a search for something like "ajax innerhtml"... I'm sure there are plenty of tutorials out there on the subject.

    http://www.google.com/search?q=ajax+innerhtml+examples


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •