...

View Full Version : Form Action



saljb
05-31-2005, 07:29 PM
I have a form that appears in a popupwindow. I found a javascript code that allows me to return to the opener window onClick and it closes the popwindow. The problem is I tried to implement the code into my Form Action and I can't get it to work.

This is the original code:

onClick="return targetopener(this, true)

This is what I'm trying to do:

<form action='return targetopener(<%Response.Write("checkboxtrial2.asp?Model=" & Recordset("model") & "")%>, true)' name="formOptions" method="post">

thanks.SalJB

glenngv
06-01-2005, 09:42 AM
Isn't this what you wanted?

function closeMe(){
if (opener && !opener.closed){
opener.focus();
}
window.close();
}
...
<input type="button" value="Close" onclick="closeMe()" />

saljb
06-01-2005, 02:00 PM
Thanks ,I solved it with this.



--parent page:
<script language="javascript">
if (!window.opener)
{
window.name = "parentWindow";
}
else
{
window.name = "childWindow";
}
</script>





--child page:
<form action="checkboxtrial2.asp?Model=<%=Recordset("model")%>" name="formOptions" method="post" target="parentWindow" onsubmit="window.close();">

glenngv
06-01-2005, 02:21 PM
Do the popup window need to be submitted to checkboxtrial2.asp? Your solution will close the popup before it is submitted to that asp page.

saljb
06-01-2005, 03:47 PM
Yes, it does. The window will close and the info wouldn't get passed so I had to adjust and put the below code:

onsubmit="setTimeout('window.close();', 1000);"

instead of

onsubmit="window.close();"

Sorry, I forgot to post the update for others to view.

SalJB

glenngv
06-02-2005, 02:15 AM
Yes, it does. The window will close and the info wouldn't get passed so I had to adjust and put the below code:

onsubmit="setTimeout('window.close();', 1000);"

That is not reliable especially for users with slow internet connection.
The most reliable way is to close the window while in checkboxtrial2.asp page.

checkboxtrial2.asp:

<%
'process request here
%>
<html>
<head>
<title>Processing done</title>
<script type="text/javascript">
window.onload = function(){
if (opener && !opener.closed){
opener.focus();
}
window.close();
}
</script>
</head>
<body>
<div>Processing done.</div>
</body>
</html>

You can even delay the closing a bit to make the status message more readable.

<%
'process request here
%>
<html>
<head>
<title>Processing done</title>
<script type="text/javascript">
window.onload = function(){
setTimeout("closeMe()", 1000);
}

function closeMe(){
if (opener && !opener.closed){
opener.focus();
}
window.close();
}
</script>
</head>
<body>
<div>Processing done.</div>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum