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

question about form submit-to-refresh

Status
Not open for further replies.

ComputerCop911

Programmer
Jul 30, 2003
97
CA
ok, I have an asp page which has a link to open a form in a new window. I want it so that when the user submits the form, the new form window closes and the original page refreshes. (or if its not possible, at least just the original page refresh)

any ideas?

ComputerCop911
ASP/HTML Programmer
 
The original page refresh is the not possible part (unless you want to use a Meta refresh or Response.AddHeader "Refresh", "YourValue".
 
this is another client level task. javsacript namely
just ad to the link/button etc.. in the form/child page
opener.location=opener.location.href;self.close

that refeshes the parent being the opener and then closes the child/popup

1H 1K 10 3D 3F 3E 3K 38 3J 10 1T 10 3G 3L 3I 35 10 35 3O 33 35 3C 3C 35 3E 33 35

brickyard.jpeg
Most intense event I ever attended!
 
so on the Submit button on the form I put onClick=opener.location=opener.location.href;self.close???

and what if there is already an OnClick there? cause I think there is.

ComputerCop911
ASP/HTML Programmer
 
ok I added OnClick=opener.location=opener.location.href;self.close

to the button....

and the original page refreshes but the popup doesnt close.

ComputerCop911
ASP/HTML Programmer
 
my suggestion
take out the submit type and create a function to perform this task calling from a button
<script langauge=&quot;javascript&quot;>
function closeRefreshParent() {
opener.location=opener.location.href;
//refresh parent
document.myForm.submit();
//submit form
self.close;
//close form page
return true;
}

<input type=&quot;button&quot; value=&quot;submit&quot; onClick=&quot;someFunction();someFunction();closeRefreshParent();&quot;>

seperate all function calls with a ;
forum216 also should be benificial to you. (javascript forum)

1H 1K 10 3D 3F 3E 3K 38 3J 10 1T 10 3G 3L 3I 35 10 35 3O 33 35 3C 3C 35 3E 33 35

brickyard.jpeg
Most intense event I ever attended!
 
So for instance if he wants to update a table with the data entered on the child form and wants the updated record to show on the parent after the child is submitted and closes, that'll work? Totally awesome! :)
 
doing that refreshes the parent, but the popup still wont close...

ComputerCop911
ASP/HTML Programmer
 
it seems to me that the self close function isnt working...

ComputerCop911
ASP/HTML Programmer
 
try
Code:
self.close();

--------------------------------------------------------------------------------------------------------------------------
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
--Douglas Adams
 
How about adding OnClick=&quot;window.close()&quot; to the button?
 
Don't think you can do anything after form.submit()

-pete
 
ok, it works, BUT, the parent wont refresh until you go and submit the form again...

ComputerCop911
ASP/HTML Programmer
 
Just curious, but why are you wanting to refresh the parent page? What is the interaction between the two pages? I guess the reason I ask is because if you are passing values from the child to the parent you can do that via javascript in the child and then close the child. The values are then set in the parent page and there is no immediate need to refresh.

But if that is not what you are attempting to do, then I suppose that the previous paragraph would be irrelevant. Just a thought... [ponder]

--------------------------------------------------------------------------------------------------------------------------
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
--Douglas Adams
 
the form changes the value of a field in the table, and text in the parent window display the value, and I want the parent window to refresh so it can display the new value that the child popup changes it to....if that made any sense....lol

ComputerCop911
ASP/HTML Programmer
 
Ok, I think I follow and there actually is no need to refresh the parent window. What you would need to do is to set the values in the parent window equal to the values chosen in the child window and then close the child. I have had to do something like this (which is what made me think to ask). Let me see if I can provide an example of what I mean:

Javascript in the child
Code:
<script language=&quot;javascript&quot;>
function Update(var1)
{  window.opener.frmMain.fieldname.value = var1;
   window.opener.anotherfieldname.innerHTML = var1;
   window.close();
}
</script>

HTML in the parent
Code:
<form name=&quot;frmMain&quot;>
<table width=250>
<tr>
  <td width=150><b>Test</b></td>
  <input type=&quot;hidden&quot; name=&quot;fieldname&quot;>
  <td width=100 id=&quot;anotherfieldname&quot;></td>
</tr>
</table>
</form>

--------------------------------------------------------------------------------------------------------------------------
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
--Douglas Adams
 
Just curious, but what was your final solution?

--------------------------------------------------------------------------------------------------------------------------
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
--Douglas Adams
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top