Avatar of kevbob650
kevbob650
Flag for United States of America asked on

Reload data in div tag

I have a php page with two <div>'s in which I load external php pages. They load fine, but when I try to do a submit in one of the external files, the parent page is populated with only the form data from the div tag page. I thought it would be the same as an iframe but apparently not!
I have the external php page set up like a full html page with form and form action etc. Not sure how to get this working . I had the data in an iframe but I need to do an auto reload every 10 second and I don't want the iframe to reload, hence I'm using a series of <div> that I can refresh individually.
Scripting LanguagesJavaScript

Avatar of undefined
Last Comment
kevbob650

8/22/2022 - Mon
Barry62

If you have the action of your external forms set to the parent page, you will need to create and populate hidden fields in the external forms for the data you want to re-populate on the parent page.  PHP will only keep data from the currently submitted form.

You could use cookies to keep your parent page data.
kevbob650

ASKER
I was thinking I would have the action of the external page to be itself as I would in an iframe application. So do I need to set the action to the parent page?
COBOLdinosaur

Can you post a like to the page? It sounds like the structure is invalid which will probably create all kinds of problems anyway.

Cd&
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
kevbob650

ASKER
I can't get you a link, but here's the structure (can't seem to attach a file?)...



Parent page:

<html>
<head>
<script type=”text/javascript”>
$(document).ready(function(){
      $("#dailyCounts").load("dailyCounts.php");
      $("#countSummaries").load("countSummaries.php");
      $("#history").load("history.php");
});
</script>
<table>
    <tr>
             <td>
      <div id=”dailyCounts”></div>
       </td>
       <td>
      <div id=”countSummaries”></div>
       </td>
   </tr>
   <tr>
      <td>
      <div id=”history”></div>
     </td>
   </tr>
</table>


dailyCounts.php
page with mysql, refesh routine updating every 10 seconds:
<script>
    $(document).ready(function() {
        setInterval("location.reload(true)", 10000);  // every 10 seconds        
    });
</script>


countSummaries.php
page with mysql queries
<form> with <select> box and submit to update display
no auto_reload routines


history.php
page with mysql queries
<form>
<select> boxes and submit to update display
and a jqery refresh routine
<script>
    $(document).ready(function() {
        setInterval("location.reload(true)", 30000);  // every 30 seconds        
    });
</script>
COBOLdinosaur

I started to do a long winded technical exploration which was getting confused when I realized that this can be put quite simply.  Content in a div can never be a window object.  The content of an iframe is always a window object.  To maintain the context you need, you need the a parent window to child window relationship.

Barry's suggestion of cookies is dicey, but you might be able to make it work.  Trying to make a div behave like an iframe is like expecting a pet dog to run in the Kentucky Derby.

Cd&
kevbob650

ASKER
LOL,  so that being said, what's the best way to accomplish this?  iframes?  if so, how can I prevent the parent page from flickering when the iframes reload?  frustrating!
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
COBOLdinosaur

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
COBOLdinosaur

What is with the C?  Either it does not give you what you need and we should be looking to see if more can be done, or it solved the problem in which case a C is inappropriate.  


Cd&
kevbob650

ASKER
no it didn't solve the problem, all it did was send me on to other sources, so the C is appropriate
COBOLdinosaur

If it did not solve the problem, it should not be accepted at any grade.  If you found a solution elsewhere, post it and ask CS to accept your comment as the answer, or if you don't want to pursue it further then ask them to delete the question.

Cd&
Your help has saved me hundreds of hours of internet surfing.
fblack61
kevbob650

ASKER
this is crap, delete the question. I'll always award an A for every solution in the future.