• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 573
  • Last Modified:

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

0
chrscote
Asked:
chrscote
1 Solution
 
BadotzCommented:
What does

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

accomplish?
0
 
chrscoteAuthor Commented:
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.
0
 
BadotzCommented:
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.).
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
agamalCommented:
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

0
 
BadotzCommented:
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.
0
 
chrscoteAuthor Commented:
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.
0
 
BadotzCommented:
OK, its your call. Sorry I can't be of more help.
0
 
sybeCommented:
Do I understand it right that you just need to update a single numeric value in the parent iframe?

-----
<parent_iframe>
 
<script>
function UpdateNumberOfBooks(value) {
    document.getElementById('numberofbooks').innerHTML = value;
}</script>
 
<span id="numberofbooks">25</span>
 
</parent_iframe>
-----
 
<child_iframe>
<%
' some ASP code that gives the newvalue
iNewValue = <databaseresult>
%>
 
<script>
parent.UpdateNumberOfBooks(<%=iNewValue%>);
</script>
 
</child_iframe>
----

Open in new window

0
 
chrscoteAuthor Commented:
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.
0
 
chrscoteAuthor Commented:
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.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now