/    Sign up×
Community /Pin to ProfileBookmark

how to close the popup window when submitting the form?

How to close the popup window when submitting the form?

I have a sample.jsp. In that page one button is there.
when button pressed, open popup window contains one “text box” and one ” submit button”. when “submit” button pressed, call the “servlet” in this popup window and then close the “popup” window.

<SCRIPT LANGUAGE=”JavaScript”>

<!– Begin

var X = 200; // change the # at the left for a fixed X co-ordinate to accommodate browsers other than IE or NS

var Y = 200; // change the # at the left for a fixed Y co-ordinate to accommodate browsers other than IE or NS

if (navigator.appName.indexOf(“Netscape”)!=-1) {

document.captureEvents(Event.MOUSEMOVE)

function getcoords(e) {

X = parseInt(e.screenX) – 80; // change the # at the left to further adjust the left-margin depending on the size of the window

Y = parseInt(e.screenY) – 60; // change the # at the left to further adjust the top-margin depending on the size of the window

return true;}

document.onmousemove = getcoords;

function openWin() {

if (navigator.appName.indexOf(“Microsoft”)!=-1) {

X = parseInt(event.screenX) – 80; // change the # at the left to further adjust the left-margin depending on the size of the window

Y = parseInt(event.screenY) – 60; } // change the # at the left to further adjust the top-margin depending on the size of the window

display=window.open(”,’NewWin’,’menubar=0,location=no,status=no,directories=no,toolbar=no,scrollbars=yes,height=30,width=230′)

message=”<font face=’verdana, arial, helvetica, san-serif’ size=’2′>”;

message+=”<form name=’form1′ action=’./SaveFile’>”;

message+=”Enter Query Name:”;

message+=”<input type=’text’ name=’query_name’ />”;

message+=”<input type=’submit’ value=’GO’/>”;

message+=”</form></font>”;

display.moveTo(X,Y);

display.document.write(message); }

}

// End –>

</script>

The above code calls the “servlet” but didn’t cose the popup window.

modify the above code with below code
message+=”<input type=’submit’ value=’GO’ onClick=’window.close()’/>”;
then when submit button pressed in popupwindow that window will be closed but didn’t call the servlet.

plz help me, how to close the popup window after submitting the form in popupwindow.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@FangAug 27.2008 — message+="&lt;form name='form1' action='./SaveFile' onsubmit='this.submit(); self.close(); return false;'&gt;;
Copy linkTweet thisAlerts:
@dittuauthorAug 28.2008 — same problem raised.

didn't submit the form action but close the window.

is there any way to solve the above problem? plz help me.
Copy linkTweet thisAlerts:
@FangAug 28.2008 — Try closing it from the parent window:// in the child
&lt;form name='form1' method='post' action='postIt.php' onsubmit='opener.closeChild(); return false;'&gt;

// in the parent
var display=null;
function closeChild() {
display.document.form1.submit();
setTimeout("display.close()",3000);
}
You may or may not require the setTimeout

Ideally the child window should call it's self:&lt;form action="&lt;?php echo $_SERVER['PHP_SELF']?&gt;" method="post" name="form1"&gt;This way a value set in the php script can determine if the form should be displayed or the window closed.
×

Success!

Help @dittu spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...