/    Sign up×
Community /Pin to ProfileBookmark

closing child modal window with a submit button

Hey guys,
So i want to close the child modal window when the users clicks on the a submit button that is also located in the same child modal window. I am currently using this line to open the modal window.

var entry_win= window
entry_win = window.showModalDialog(“AddPerson.htm”,”Add”, “dialogWidth=205px;dialogHeight=280px;resizab
le:yes;dialogLeft:100;dialogTop:100″);

I added self.close()and window.close() in the child modal window, but that just seemed to open another window and load the child modal page again.

Can anyone help?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@7studNov 07.2004 — Hi,

window.close() worked fine for me. This is what my popup page looked like:
<i>
</i>&lt;!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en"&gt;
&lt;head&gt;
&lt;title&gt;Web Design 1&lt;/title&gt;
&lt;meta name="author" content="Mr. Smith, I presume" /&gt;
&lt;meta name="description" content="web" /&gt;
&lt;script language="javascript"&gt;
&lt;!-- Hide from browsers lacking javascript

window.onload=function()
{
document.getElementById("b1").onclick=function(){window.close()};

};

// End hiding --&gt;
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;div&gt;some text&lt;/div&gt;
&lt;input type="submit" name="b1" value="submit" /&gt;

&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@7studNov 07.2004 — I see what you're saying now. ? It has to do with the 'action' attribute of the form for the submit button. I don't have a solution.
Copy linkTweet thisAlerts:
@orweiauthorNov 08.2004 — SO i discovered that the child modal window with the submit cannot be a type=submit. Instead it must be a type=button for it to work properly. This was a very odd bug to find, but luckly my awesome roomate suggested such a fix.

Later,

orwei
Copy linkTweet thisAlerts:
@7studNov 08.2004 — But, then how do you submit the data? Or, do you not have any data, and you just want the window to close on the click of a button?
×

Success!

Help @orwei 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...