Link to home
Start Free TrialLog in
Avatar of chrscote
chrscoteFlag for United States of America

asked on

Reloading parent iframe from within child iframe

I have a page with an iframe to display records from a query.  Now this iframe also includes another iframe that will display another set of records from another table that are associated with each record.  The problem I'm having is that when I add a new item to the inner-most iframe's query, the outer iframe doesn't update the number of records that exist.
    To try an make it clearer, imagine you have a list of employees each with a list of books they have in their possession.  The employee iframe would have the person's name, room number, etc.  Then you would have a second iframe within the employee page that gives each employees books and the pertinent data for each book (like title, author, etc).
    The form has the usual previous/next buttons to page through each employee and/or book along with "1 of 10".  Now when an employee buys a new book and adds it to the database, the employee page doesn't reload to update the number of books.
   My code below uses ECD.asp for the outer iframe page (employees) and ECD_propsSubform.asp as the inner iframe (books).  The outer iframe is named "ecProp"
<html>
<head>
    <title>ECD Form</title>
    <LINK rel="stylesheet" type="text/css" href="dataview2.css"/>
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache" />
    <script type="text/javascript">
        function reload(){
           parent.ecProp.src=parent.ecProp.src;
        }
    </script>
<body onload="reload();">
... data here for "books" 
</body>
</html>

Open in new window

Avatar of Badotz
Badotz
Flag of United States of America image

What does

parent.ecProp.src=parent.ecProp.src;

accomplish?
Avatar of chrscote

ASKER

I had been using something similar with pages to reload them using parent.location.href=parent.location.href.  This simply reloads the page without having to know the actual page it's on.
What's the point?

I mean, using Ajax might be a better idea for this (no page reloading, specific HTML elements can be targeted, etc.).
as you said ... just use the attached script to be run after edition the books iframe


<script language="JavaScript" type="text/javascript">
parent.location.href=parent.location.href;
</script>

Open in new window

Right, but isn't there a better way to refresh an element? Blindly refreshing the entire <firame> will flicker and flash (very distracting), whereas using Ajax will allow you to refresh single *elements*, not the entire bloody page.
Well, at the current time, our customer would like the site to be done using ASP.  Also, I've never actually coded in Ajax, so it would require a bit of a learning curve for me and we don't have enough time in the schedule to start on a whole new track.
OK, its your call. Sorry I can't be of more help.
ASKER CERTIFIED SOLUTION
Avatar of sybe
sybe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry it took so long to get back to you.  I've been sidetracked on other projects.  Yes, that is all I need to do is update a single value if the user is adding an item.
WOW! That worked excellent!  Thank you very much for the help.  Once again, I'm sorry it took so long to respond, but I was pulled away from this project to work on something else.