Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

refreshing and ilayer or iframe after some updating

Status
Not open for further replies.

sandravega

Programmer
Feb 10, 2004
43
AR
Hi
this is my first in this forum. I have a problem I think should be solved with javascript and ilayers, or Iframes but I'm not sure.
I have a form (an asp one) where users update information about movies. There is a select where they can choose the type of the movie (if it is for kids, if it is a drama and so on).
If the movie type is not already in the select list, the user can call a popup window and add it.
Now comes the problem: I need to close the window, refresh the select but not refresh the entire form, wich already has some of the inputs filled with data.
I think the answer is using an ilayer or an iframe (don't know exactly wich of them) as a container for the select and use some javascript function from the popup window to refresh just this portion of the html.
I used "window.opener.reload()" statement to refresh the first form from the popup window, but obviously this refreshes all the form and deletes data that is already filled in by the user.

Well, that was a long answer. Thank you all.

Sandra Vega
 
This doesn't repopulate a dropdown or anything, but it does show how the relationship between an iframe, a popup window, and the main window can accomplish what you're trying to do. Here's some sample code to open a page with a button and a textbox. When the button is pushed it opens a popup with a button. When the button on the popup is pushed it closes the popup and refreshes the iframe on the main page, which then changes the value of the textbox.

popuptest.html:
Code:
<html>
<head>
<script language=javascript>

function newWindow() {
   blahForm.blahHidden.value = 1;
   popwin = window.open("popupwindow.html", "", "width=300,height=200, scrollbars=no,resizable=no,left=100,top=100");
}

function setText(blah) {
   blahForm.blahText.value = blah;
}

function reloadIframe() {
   blahFrame.location.reload()
}

</script>
</head>
<body>
<form name=blahForm>
<input type=button value='Click me' onclick='newWindow()'><br>
<input type=text name=blahText size=25>
<input type=hidden name=blahHidden value=0>
<iframe name=blahFrame src='iframetest.html' width=0 height=0></iframe>
</form>
</body>
</html>
popupwindow.html:
Code:
<script language=JavaScript>

function refreshIframe() {
   opener.reloadIframe();
   self.close();
}

</script>
<body>
<form name=blahForm>
<input type=button value='Refresh Iframe' onclick='refreshIframe()'>
</form>
</body>
iframetest.html:
Code:
<script language=JavaScript>

function reloadFunction() {
   if (parent.blahForm.blahHidden.value == 1) {
      parent.blahForm.blahText.value="Iframe has been reloaded"
   }
}

</script>
<body onload='reloadFunction()'>
<form name=blahForm>

</form>
</body>

-kaht

banghead.gif
 
Kaht:
thank you for replying, I just tried it but...I have some message error (in the main page) than says
that the var uses an automatization type that is not accepted in Javascript (As I'm an spanish speaker my browser is in spanish, I'm translating the message. I'm using IE 6.0)

The error line number corresponds to this statement of the popuptest.html :

blahFrame.location.reload()

and it doesn't refresh the input text. I dont't know enough java to solve this... If you're so kind...

thank you very much anyway

Sandra
 
I am also using IE6 and pasting those 3 bits of code into the html files that I mentioned works perfectly fine for me.....

-kaht

banghead.gif
 
Hi Kaht,
You were right, I was having trouble with the google bar.
Now I just have to know how to pass an asp array to a javascript function...
Thanks a lot anyway, you're being most helpfull

Sandra
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top