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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

make a page refresh while I'm on another

Status
Not open for further replies.

andycape

Programmer
Joined
Aug 22, 2003
Messages
177
Location
ZA
If I am one one page and I submit something (an entry into the database), is there a way to send a command to another page to refresh ?
(the other page is open aswell in a different window and I would need it to refresh so that it shows the new information from the database)

thanx.
 
I didnt mention - the first page (the one i want to refresh) is the parent of the 2nd (the one that I am submitting information on).
 
place this at the bottom of the submit function of the page (the one that you are submitting information on)

top.window.opener.location.replace(URL);

The URL is the url of the parent window.
 
I will try that, I also found

window.opener.parent.location.reload(true);

would this work too ??

what is meant by location. ? (what must i put there, the form name ?)

thanx.
 
both methods will work for your needs.

Very briefly: location describes the URL information for the window in question. you don't and must not put the form name there.
 
sorry - silly question, i worked that out.

But this dosnt really work as it refresh'e the page as soon as i open the new page, not once i have clicked the submit button. If i excecute it after i have clicked the submit button it then tries to refresh the page that it went to while submitting.

I have tried to put it as an onclick function when clicking the submit button, nothing seems to happen?

This is definatly the right method, its just getting it to do it at the right time ! :-)
 
Its a huge page so i just kept the bit that does the submit : Here I am trying to use the onclick function (nothings happening), because if i run the script as i enter the pop up it will refresh the parent straight away.
(this is the pop-up)

<form name=&quot;myform&quot; action=&quot;../Forms/SendMailForm.asp&quot; method=&quot;post&quot;>
<table bgcolor= &quot;cccccc&quot; style=&quot;width:500px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;1&quot;>
<table style=&quot;width:500px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot;>
<tr>
<td><input type=&quot;button&quot; class=&quot;button&quot; name=&quot;close&quot; value=&quot;Close&quot; onclick=&quot;window.close()&quot; style=&quot;width:100&quot;></td>
<td><div align=&quot;right&quot;><input type=&quot;submit&quot; class=&quot;button&quot; onclick=&quot;click()&quot; name=&quot;submit&quot; style=&quot;width:115&quot; value=&quot;Approve / Decline >&quot;></div></td>
</tr>
</table>
</form>

<script language=&quot;javascript&quot;>
function click()
{
top.window.opener.location.replace('../Forms/PetrolReport2.asp?EmpView=<%= Request(&quot;UserID&quot;) %>&Status=<%= Request(&quot;Status&quot;) %>&ToDate=<%=Request(&quot;ToDate&quot;) %>&FromDate=<%= Request(&quot;FromDate&quot;) %>');
}
</script>
 
first you should have your script code at the very beginning of the page between the <head> and </head> tags.
<head>
<script language=&quot;Javascript&quot;>
<!--
function click()
{
top.window.opener.location.replace('../Forms/PetrolReport2.asp?EmpView=<%= Request(&quot;UserID&quot;) %>&Status=<%= Request(&quot;Status&quot;) %>&ToDate=<%=Request(&quot;ToDate&quot;) %>&FromDate=<%= Request(&quot;FromDate&quot;) %>');
}
//-->
</script>

then the form should be like this.

<form name=&quot;myform&quot; action=&quot;../Forms/SendMailForm.asp&quot; method=&quot;post&quot; onSubmit=&quot;javascript:click();&quot;>
<table bgcolor= &quot;cccccc&quot; style=&quot;width:500px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;1&quot;>
<table style=&quot;width:500px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot;>
<tr>
<td><input type=&quot;button&quot; class=&quot;button&quot; name=&quot;close&quot; value=&quot;Close&quot; onclick=&quot;window.close()&quot; style=&quot;width:100&quot;></td>

//take out the onclick event handler
<td><div align=&quot;right&quot;><input type=&quot;submit&quot; class=&quot;button&quot; name=&quot;submit&quot; style=&quot;width:115&quot; value=&quot;Approve / Decline >&quot;></div></td>

</tr>
</table>
</form>

I haven't tested this code yet but this is the idea.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top